Create excel ranges using column numbers in vba?

前端 未结 9 2210
误落风尘
误落风尘 2021-02-02 05:56

How is it possible to create a range in vba using the column number, rather than letter?

9条回答
  •  生来不讨喜
    2021-02-02 06:14

    Function fncToLetters(vintCol As Integer) As String
    
            Dim mstrDigits As String
    
        ' Convert a positive number n to its digit representation in base 26.
        mstrDigits = ""
        Do While vintCol > 0
            mstrDigits = Chr(((vintCol - 1) Mod 26) + 65) & mstrDigits
            vintCol = Int((vintCol - 1) / 26)
        Loop
    
        fncToLetters = mstrDigits
    
    End Function
    

提交回复
热议问题