+ Reply to Thread
Results 1 to 4 of 4

Macro using Chr function to select double-lettered columns

  1. #1
    Registered User
    Join Date
    10-11-2017
    Location
    Hong Kong
    MS-Off Ver
    2019
    Posts
    55

    Macro using Chr function to select double-lettered columns

    Dear all,

    I want to use Chr function to select multiple columns as the coding contains variable. However, if the column is double-lettered column, the coding would have error.

    For example:

    temp = 22
    Columns(Chr(64 + temp + 3) & ":" & Chr(64 + temp + 4)).Select

    Column Y and Z will be selected.

    temp = 23
    Columns(Chr(64 + temp + 3) & ":" & Chr(64 + temp + 4)).Select

    Supposed Column Z and AA will be selected. However as Chr(91) is not AA so the coding would have error.

    How can I prevent this error? Or is there any other coding instead of using Chr function to get the same result? Thanks.

    Jack

  2. #2
    Forum Contributor
    Join Date
    04-15-2015
    Location
    beirut
    MS-Off Ver
    2010
    Posts
    107

    Re: Macro using Chr function to select double-lettered columns

    try this example,
    you can choose the values of temp and x
    Please Login or Register  to view this content.
    Or For many specific selection
    Please Login or Register  to view this content.
    Last edited by salim ali; 09-26-2019 at 12:33 AM.

  3. #3
    Valued Forum Contributor
    Join Date
    02-02-2016
    Location
    Indonesia
    MS-Off Ver
    Office 365
    Posts
    1,004

    Re: Macro using Chr function to select double-lettered columns

    Try this:

    Please Login or Register  to view this content.
    Edit: Sorry, it is easier like this:

    Please Login or Register  to view this content.
    Last edited by Akuini; 09-26-2019 at 12:11 AM.

  4. #4
    Registered User
    Join Date
    10-11-2017
    Location
    Hong Kong
    MS-Off Ver
    2019
    Posts
    55

    Re: Macro using Chr function to select double-lettered columns

    Hi all,

    Thanks for the coding. It works perfectly. Really appreciate!

    Jack

+ 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. [SOLVED] Macro to select columns, call a macro, then shift 11 columns and run again in loop
    By Groovicles in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-12-2016, 12:24 PM
  2. Macro works until columns are double letters
    By d_rose in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-10-2015, 02:00 PM
  3. Numbered columns and lettered rows?
    By dblword in forum Excel General
    Replies: 5
    Last Post: 10-13-2009, 06:49 AM
  4. Column headers being numbered, not lettered?
    By robbert in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-23-2009, 10:32 AM
  5. [SOLVED] Excel columns are now numbered instead of lettered
    By Kelly in forum Excel General
    Replies: 3
    Last Post: 05-25-2006, 02:45 PM
  6. Replies: 1
    Last Post: 04-25-2006, 01:50 PM
  7. Replies: 1
    Last Post: 01-07-2006, 06:45 PM

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