Results 1 to 4 of 4

Thread: getting column name given column number
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    Jul 2002
    Posts
    16
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Is there any built in function in Excel VBA to get the column name given the column number, ie column 63 is "BK" so I need something like

    colnam=getcol(63)

    and should return "BK" in colnam

    Thanks

  2. #2
    MrExcel MVP Andrew Poulsom's Avatar
    Join Date
    Jul 2002
    Posts
    73,092
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    3 Thread(s)

  3. #3
    New Member
    Join Date
    Jul 2002
    Location
    Liverpool, England
    Posts
    31
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Couldn't find a built in function - had to create a User Fuction for this.

    '======================================
    Function GetCol(ColumnNumber)

    FuncRange = Cells(1, ColumnNumber).AddressLocal(False, False)
    'Creates Range (defaults Row to 1) and retuns Range in xlA1 format

    FuncColLength = Len(FuncRange)
    'finds length of range reference

    GetCol = Left(FuncRange, FuncColLength - 1)
    'row always "1" therefore take 1 away from string length and you are left with column ref

    End Function
    '======================================

    In a separate Module

    Colname = GetCol(63)

    Will return Colname as 'BK'

  4. #4
    New Member
    Join Date
    Jul 2002
    Posts
    16
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Thanks alot, that is very helpfull



Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •