随着手机里面功能越来越丰富,让我们使用起来越来越方便了,给我们的生活带来了极大的便利。怎样使用VBA返回列号对应之英文字母?

方法/步骤
-
1
首先在开发工具中打开VBA编辑器
-
2
在单元格区域当中输入一些内容作为例子
-
3
在VBA编辑器中插入模块
-
4
在模块当中输入如下代码,然后运行
Function Col(Optional ColNum) As String '返回指定列的列号,参数为可选
Application.Volatile
If Not VBA.IsNumeric(ColNum) Then Coll=""
If VBA.IsNumeric(ColNum) Then '如果输入的是数字
If ColNum > 16384 Or ColNum < 1 Then Col="超出范围": Exit Function
'不能大于16384或者小于1
Col=Left(Cells(1, ColNum).Address(0, 0), 1-(ColNum > 26)-(ColNum > 702))
'取得列号
Exit Function
End If
'如果不输入参数,则返回当前列的列号
Col=Left(Cells(1, ActiveCell.Column).Address(0, 0), 1 –
(ActiveCell.Column > 26)-(ActiveCell.Column > 702)) '取得列号
End Function
-
5
在单元格A1中输入公式“=col()”,因省略了参数,则单元格显示当前列的列号“A”
END
文章评论