首页 > 编程语言 > 详细

vba 数字变为excel对应列的字母

时间:2018-12-09 13:31:41      阅读:294      评论:0      收藏:0      [点我收藏+]

Public Function GetColName(ByVal y As Integer) As String
       Dim z     As Integer
       Dim i     As Integer
       Dim n(25)     As String

       For i = 0 To 25
               n(i) = Chr(65 + i)
       Next

       If y <= 26 Then
         GetColName = n(y - 1)
         Exit Function
       End If
      
       z = y \ 26
      
       If y Mod 26 = 0 Then
         GetColName = n(z - 2)
       Else
         GetColName = n(z - 1)
       End If
     
       z = y Mod 26
       If z > 0 Then
             GetColName = GetColName & n(z - 1)
       Else
             GetColName = GetColName & "Z"
       End If
  End Function

vba 数字变为excel对应列的字母

原文:https://www.cnblogs.com/bignine/p/10090558.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!