如何在vba中把数字列转成字母ALt+F11,插入模块,插入如下代码 Private Function ColumnNum(ByVal a) As Long Dim r r = 0 If VarType(a) = vbString And Len(a) > 0 Then a = UCase(a) r = Asc(Left(a, 1)) - Asc("A") + 1 If Len(a) >= 2 Then r = r * 26 + Asc(Mid(a, 2, 1)) - Asc("A") + 1 If Len(a) >= 3 Then r = r * 26 + Asc(Mid(a, 3, 1)) - Asc("A") + 1 End If End If End If ColumnNum = r End Function 然后返回Excel,用函数=ColumnNum(需要转换的单元格) 即可实现数字列换成字母
|