+ Reply to Thread
Results 1 to 3 of 3

Getting the true Column letter using Chr

  1. #1
    Registered User
    Join Date
    01-31-2005
    Posts
    11

    Getting the true Column letter using Chr

    Hi,

    I am having a problem with the following loop...


    Please Login or Register  to view this content.
    The problem is that if the spreadsheet has a column "AA" then it returns sCol as "]", when I need it to return "AA"

    Thanks

    Stephen

  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
    Hello Stephen,

    The loop requires a little more math to work properly. Here is the revised version.
    _________________________________________________________________

    Dim I As Integer
    Dim Tens As Integer
    Dim Ones As Integer
    Dim ColAddx As String

    For I = 1 To TotalCols

    Ones = I Mod 27
    Tens = I \ 27

    If Tens = 0 Then
    ColAddx = CHR$(Ones + 64)
    Else
    ColAddx = Chr$(Tens + 64) & Chr$(Ones + 64)
    End If

    Next I

    _________________________________________________________________

    Hope this helps,
    Leith Ross

  3. #3
    Registered User
    Join Date
    01-31-2005
    Posts
    11
    Nice solution.

    Thanks a lot!

+ 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