Convert Excel Column Number into Column Name

Update:

Sorter version of the VBA function:

Function Number2Char(c As Integer) As String
   Number2Char = Split(Cells(1, c).Address, "$")(1)
End Function

Courtesy of The Plaid Cow.

OR

Function Number2Char(ByVal vNumber)

    Dim addr As String
    If vNumber  256 Then Exit Function

    addr = Range("A1").Offset(0, vNumber - 1).Address
    Number2Char = Replace(Replace(addr, "$", ""), Range(addr).Row, "")

End Function

Courtesy of Stan Scott.

Original post:

Converting Excel column number into column name, for example 1 into A or 52 into AZ, is needed occasionally, and the following function will do the convertion for us.

Function Number2Char(ByVal vNumber)
    Dim iDiv As Double, iMod As Integer
    If vNumber < 1 Then Exit Function

    iDiv = vNumber
    While iDiv > 26
        iMod = iDiv Mod 26
        If iMod = 0 Then
            iMod = 26
            iDiv = iDiv - 1
        End If
        Number2Char = Chr(64 + iMod) & Number2Char
        iDiv = iDiv \ 26
    Wend

    Number2Char = Chr(64 + iDiv) & Number2Char
End Function

Use this function as formula in the Excel formula bar, ex: =NUMBER2CHAR(52)

FIN.

This entry was posted in Workbook and Worksheet and tagged , , , , , , , , , , , . Bookmark the permalink.

984 Responses to Convert Excel Column Number into Column Name

  1. Pingback: auto quote reviews

  2. Pingback: www

  3. Pingback: paycheck advance

  4. Pingback: lecterns

  5. Pingback: office supplies & equipment

  6. Pingback: embarrassing

  7. Pingback: research tacotime

  8. Pingback: Creation Site Internet Annecy

  9. Pingback: fun times

  10. Pingback: schools canada

  11. Pingback: va loan credit score requirements

  12. Pingback: natural health

  13. Pingback: Garmin GPS

  14. Pingback: Electric Airsoft Guns

  15. Pingback: Peripheral

  16. Pingback: Software

  17. Pingback: sub zero freezer repair parts

  18. Pingback: more information

  19. Pingback: tropical shakeology

  20. Pingback: jungle theme party

  21. Pingback: blog

  22. Pingback: instant payday loans

  23. Pingback: url

  24. Pingback: www.easyloanfast.com

  25. Pingback: free scrabebox list

  26. Pingback: in english

  27. Pingback: fast cash loans reviews

  28. Pingback: check this out

  29. Pingback: insurance terms

  30. Pingback: HCG Drops Reviews

  31. Pingback: promoting and celebrating Virginia creativity

  32. Pingback: fast cash advance

  33. Pingback: www.easyloanfast.com

  34. Pingback: california workers comp cost

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>