怎样使用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”
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
阅读量:43
阅读量:37
阅读量:140
阅读量:192
阅读量:162