有没有人有Excel VBA函数可以从数字中返回列字母?
例如,输入100应返回CV
。
发布于 2012-10-09 17:44:55
此函数返回给定列号的列字母。
Function Col_Letter(lngCol As Long) As String
Dim vArr
vArr = Split(Cells(1, lngCol).Address(True, False), "$")
Col_Letter = vArr(0)
End Function
第100列的测试代码
Sub Test()
MsgBox Col_Letter(100)
End Sub
发布于 2013-03-13 00:37:05
如果你不想使用range对象:
Function ColumnLetter(ColumnNumber As Long) As String
Dim n As Long
Dim c As Byte
Dim s As String
n = ColumnNumber
Do
c = ((n - 1) Mod 26)
s = Chr(c + 65) & s
n = (n - c) \ 26
Loop While n > 0
ColumnLetter = s
End Function
发布于 2013-11-22 05:00:42
对我有效的方法是:
Cells(Row,Column).Address
这将为您返回$AE$1格式引用。
https://stackoverflow.com/questions/12796973
复制相似问题