VBA excel显示列号

Sub 显示列号()
    With Worksheets("sheet1")
        .Activate
        .Range("AZ1").Select
    End With
    MsgBox Selection.Column

End Sub


Sub 测试显示列号()
    Dim intCol As Integer
    intCol = Val(InputBox("请输入列号(1~16384):"))
    If intCol < 1 Or intCol > 16384 Then
        MsgBox "输入的数据超过范围,请重新输入!"
        Exit Sub
    End If
    
    MsgBox "列号:" & intCol & ",对应的字母为:" & NumtoCol(intCol)
End Sub

你可能感兴趣的:(VBA在石油工程中应用)