+ Reply to Thread
Results 1 to 6 of 6

Use VBA to find Column Letter with Table Column Name

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    10-07-2011
    Location
    Plano, TX USA
    MS-Off Ver
    Excel 2013
    Posts
    141

    Use VBA to find Column Letter with Table Column Name

    Hello Everyone -

    I have a Table called tbl_Names that starts on Row 3 on a worksheet.

    One of the table columns is Last_Name and is on the worksheet column "C"

    Is there a vba solution which I could use to determine that "Last Name" is column "C"?

    My current code example is
    Range( "C" & ActiveCell.Row).Value
    My problem is that if I add or delete a column in the Table, the reference to column "C" could change, requiring me to go back and put in the new column.

    VBA code to get the current column by using the table column heading to replace "C" would really help me.
    Range( Some VBA CODE & Active.Cell.Row).Value
    Thanks for your assistance.
    If I was able to help you, I would appreciate your reputation feedback by using the * icon in the lower left.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: Use VBA to find Column Letter with Table Column Name

    Do you need the column letter?

    You could use the column number with Cells.
    Cells(ActiveCell.Row, ActiveSheet.ListObjects("MyTable").ListColumns("Last_Name").Range.Column)
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    10-07-2011
    Location
    Plano, TX USA
    MS-Off Ver
    Excel 2013
    Posts
    141

    Re: Use VBA to find Column Letter with Table Column Name

    Thanks Norie. That worked

  4. #4
    Forum Contributor
    Join Date
    10-07-2011
    Location
    Plano, TX USA
    MS-Off Ver
    Excel 2013
    Posts
    141

    Re: Use VBA to find Column Letter with Table Column Name

    That solution got me the column number.

    How would I get the column letter(s)?

    So, column number is 3, how do I get "C"?

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: Use VBA to find Column Letter with Table Column Name

    If you really need the column letter you could use something like this.
    ColLetter = Split(ActiveSheet.ListObjects("MyTable").ListColumns("Last_Name").Range.Address, "$")(1)
    However you should be able to use the column number in most situations.

  6. #6
    Forum Contributor
    Join Date
    10-07-2011
    Location
    Plano, TX USA
    MS-Off Ver
    Excel 2013
    Posts
    141

    Re: Use VBA to find Column Letter with Table Column Name

    OK, thanks again. I'll mark this now solved.

    Have a great weekend,
    Jim

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 8
    Last Post: 10-23-2013, 12:17 PM
  2. Find letter in column
    By treehugger in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-20-2009, 06:29 PM
  3. Code change below to find the Customer column by name rather than column letter
    By duugg in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 06-24-2009, 04:59 PM
  4. Replies: 6
    Last Post: 10-13-2005, 05:05 AM
  5. [SOLVED] How to replace column letter in refferences with a function using the old column letter?
    By Dmitry Kopnichev in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 10-13-2005, 05:05 AM

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