+ Reply to Thread
Results 1 to 6 of 6

Convert column number to letter

  1. #1
    Registered User
    Join Date
    05-05-2009
    Location
    San Diego, CA
    MS-Off Ver
    Excel 2003
    Posts
    97

    Convert column number to letter

    Is there an easy way (without writing my own conversion function) to get the column letter from a range object, as opposed to the column number?
    Last edited by gtmeloney; 07-07-2009 at 04:09 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Convert column number to letter

    Hello gtmeloney,

    This requires a Range object abd works with Excel 2000 and up.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    05-05-2009
    Location
    San Diego, CA
    MS-Off Ver
    Excel 2003
    Posts
    97

    Re: Convert column number to letter

    Thanks Leith. Appreciate it.

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Convert column number to letter

    Hello gtmeloney,

    You're welcome. Thanks for marking the post solved. Have any questions about what the code is doing?

  5. #5
    Registered User
    Join Date
    05-05-2009
    Location
    San Diego, CA
    MS-Off Ver
    Excel 2003
    Posts
    97

    Re: Convert column number to letter

    Hi Leith,

    I didn't end up using the code you submitted. I went with the following:

    Please Login or Register  to view this content.
    vRanges is an array of range objects. I don't know that this code is very sound, but it simply gets the second character from the address string. The address string looks like: $B:$B where B is the column letter that I am interested in.

    In your technique, I understand the following:

    Please Login or Register  to view this content.
    makes the address string look like: S$1.

    The "$" is the delimiting character that we need inorder to get the letter out of the range string, so in the example, the 0th index of the resulting array will consist of the "S" while index # 1 will hold "1". Index 0 being the value that I'm interested in.

    I wasn't familiar with the split function before your response, does my understanding sound about right?

    Thanks again for all of your help

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Convert column number to letter

    Hello gtmeloney.

    Right you are. A hundred percent spot on. Your code is fine. If you have a large number of conversions (1000 or more) the string functions will slow you down. For a small number of conversions you won't notice in change in performance.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1