Learn Macros‎ > ‎VBA Macros‎ > ‎

Column Number to Alphabetical reference

posted Mar 25, 2011, 8:07 AM by Ayush Jain   [ updated Mar 26, 2011, 7:37 AM ]
The below function can be used to convert any Column Number into Alphabets. example :- If you pass 1 to the function, it will Return A. If you pass 26, It will return Z. If you pass 27 It will return AA....and so on.

Public Function GetColumn(Pr)
    Dim Rn As Range
    Set Rn = ActiveSheet.Cells(1, Pr)
    GetColumn = Mid(Rn.Address, 2, InStr(2, Rn.Address, "$") - 2)
End Function


Let me know if you have better solution.
---------------------------------------------------------------
3/26 : Sit Vi(discussexcel member) has suggested an excel formula for the same task
=SUBSTITUTE(ADDRESS(1,16384,4),1,"") will return XFD
Comments