'transfer column from "A" to 1, from "Z" to 26 ......
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
vba将列名的字母转为数字
最新推荐文章于 2024-06-24 09:39:22 发布