+ Reply to Thread
Results 1 to 12 of 12

vb convert column letter to number

  1. #1
    Forum Contributor
    Join Date
    12-20-2006
    Posts
    127

    vb convert column letter to number

    Im looking for a VB way to convert a column letter to a number.

    Does anyone have a function that can do this or some code i can adapt?

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,205
    Try this.

    Please Login or Register  to view this content.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Contributor
    Join Date
    12-20-2006
    Posts
    127

    other way around

    This looks like it converts a number to a letter im asfter the other way around letter to number

  4. #4
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    With VBA code you usually do not need to convert column letters to numbers as there is usually a way to utilize letters or numbers within your commands
    commands like cell(rownumber,columnnumber or columnletter)

    Why do you need to convert column letters to numbers


    This is some code I used years ago that converts letters to numbers & a 2nd macro that converts numbers to letters. I used this when I was just starting out coding in Excel VBA in the early days of Excel 5 and have not used it since

    They are constructed as functions to be called from another macro

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    ' Convert Column Number to Letter (from Col A to ZZ)
    ' ****************************************************************



    Please Login or Register  to view this content.
    Last edited by mudraker; 03-25-2008 at 10:00 AM.
    Please Read Forum Rules Before Posting
    Wrap VBA code by selecting the code and clicking the # icon or Read This
    How To Cross Post politely

    Top Excel links for beginners to Experts

    If you are pleased with a member's answer then use the Scales icon to rate it
    If my reply has assisted or failed to assist you I welcome your Feedback.

  5. #5
    Registered User
    Join Date
    03-19-2008
    Location
    Prague, CZ
    Posts
    11
    Hi,
    I needed to do the same. My solution follows (legend: s = string with a letter or two which denote the column, a = integer representing 1st letter, b = integer representing the second letter):

    Please Login or Register  to view this content.
    Hope it helps.
    w.

  6. #6
    Registered User
    Join Date
    01-17-2011
    Location
    Cologne, Germany
    MS-Off Ver
    Excel 2003, Excel 2007, Excel 2010
    Posts
    1

    Re: vb convert column letter to number

    If anyone else looking for a solution to this problem: I believe there are easier, most likely more efficient ways to do both things:

    To convert the column letter to the column number you could use:

    Please Login or Register  to view this content.

    To convert the column number to the column letter you could use:

    Please Login or Register  to view this content.

    As an Excel workbook always needs to contain at least one visible worksheet, these two functions will always work correctly and very efficient.

    Best regards,
    Philip

  7. #7
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,298

    Re: vb convert column letter to number

    Quote Originally Posted by Khan Ego View Post
    As an Excel workbook always needs to contain at least one visible worksheet, these two functions will always work correctly and very efficient.
    That's not strictly true. A workbook needs to have one visible sheet, but it doesn't have to be a worksheet.
    Remember what the dormouse said
    Feed your head

  8. #8
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,221

    Re: vb convert column letter to number

    And another way
    Please Login or Register  to view this content.

    Hope this helps
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  9. #9
    Registered User
    Join Date
    12-23-2011
    Location
    Riga, Latvia
    MS-Off Ver
    Excel 2007
    Posts
    1

    Re: vb convert column letter to number

    one ot he fastes way ro do it

    Please Login or Register  to view this content.

  10. #10
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    MSO2007 on WinXP
    Posts
    8,582

    Re: vb convert column letter to number

    This is an old thread and should be locked and archived.
    Ben Van Johnson

  11. #11
    Registered User
    Join Date
    09-29-2012
    Location
    china
    MS-Off Ver
    Excel 2013
    Posts
    1

    Re: vb convert column letter to number

    Or maybe put into an FAQ section.

    I found it helpful.

  12. #12
    Registered User
    Join Date
    02-01-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    1

    Re: vb convert column letter to number

    A simple way to go either way:

    Number to letter:

    Please Login or Register  to view this content.
    Letter to number:

    Please Login or Register  to view this content.

+ 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