Tuesday, March 30, 2010

How to convert Column Number to Name

Using the below function you can now convert the column number to name
...for eg.. if the col no is 26 then this function would return "Z" as column name



Function Convert_Column()
    Dim MyColumn As String, Here As String

    ' Get the address of the active cell in the current selection
    Here = ActiveCell.Address

    ' Because .Address is $$, drop the first
    ' character and the characters after the column letter(s).
    Convert_Column = Mid(Here, InStr(Here, "$") + 1, InStr(2, Here, "$") - 2)
End Function

No comments:

Post a Comment