+ Reply to Thread
Results 1 to 8 of 8

How Convert number to letter more that 1 number ?

Hybrid View

  1. #1
    Registered User
    Join Date
    01-02-2022
    Location
    bangkok
    MS-Off Ver
    365
    Posts
    59

    How Convert number to letter more that 1 number ?

    I want convert number column to letter about 10 number by use vba as below.

    Dim n As Long, n2 As Long, n3 As Long
    Dim c As Byte, c2 As Byte, c3 As Byte
    Dim s As String, s2 As String, s3 As String

    n = col_header_AccNoFromIT_DataCampaign
    Do
    c = ((n - 1) Mod 26)
    s = Chr(c + 65) & s
    n = (n - c) \ 26
    Loop While n > 0

    But I write 10 round for convert number column 10 number to letter 10 number.

    How to write by short?

    Please guide me about itt.

  2. #2
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,957

    Re: How Convert number to letter more that 1 number ?

    You mean convert Column Number to letter 1 to A 2 to B etc
    Sub J3v16()
    Dim i As Long
    For i = 1 To 10
        Debug.Print Split(Cells(1, i).Address, "$")(1)
    Next i
    End Sub
    Or store numbers and convert?
    Sub J3v16()
    Dim Numbers, i As Long
    Numbers = [{1,3,5,9,10,20,25,26}]
    For i = 1 To UBound(Numbers)
        Debug.Print Split(Cells(1, Numbers(i)).Address, "$")(1)
    Next i
    End Sub
    Last edited by Sintek; 01-07-2022 at 08:23 AM.
    Good Luck...
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the [★ Add Reputation] to left of post window...
    Also....Add a comment if you like!!!!
    And remember...Mark Thread as Solved...
    Excel Forum Rocks!!!

  3. #3
    Registered User
    Join Date
    01-02-2022
    Location
    bangkok
    MS-Off Ver
    365
    Posts
    59

    Re: How Convert number to letter more that 1 number ?

    I mean store numbers.

    How to get output (letter) ?

  4. #4
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,957

    Re: How Convert number to letter more that 1 number ?

    2nd option post 2 does that...store numbers in array...get col letter output...

  5. #5
    Registered User
    Join Date
    01-02-2022
    Location
    bangkok
    MS-Off Ver
    365
    Posts
    59

    Re: How Convert number to letter more that 1 number ?

    I'm newbie in VBA.

    I don't know how to get output in array 2

    Sub J3v16()
    Dim Numbers, i As Long
    Numbers = [{1,3,5,9,10,20,25,26}]
    For i = 1 To UBound(Numbers)
    Debug.Print Split(Cells(1, Numbers(i)).Address, "$")(1)
    Next i
    MsgBox (Split(Cells(1, Numbers(i)).Address, "$")(2))
    End Sub
    Please guide me more.

  6. #6
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,957

    Re: How Convert number to letter more that 1 number ?

    Sub J3v16()
    Dim Numbers
    Numbers = [{1,3,5,9,10,20,25,26}]
    Debug.Print Split(Cells(1, Numbers(2)).Address, "$")(1)
    End Sub

  7. #7
    Forum Expert
    Join Date
    10-11-2021
    Location
    Netherlands
    MS-Off Ver
    365
    Posts
    1,505

    Re: How Convert number to letter more that 1 number ?

    To load in a new array

    Sub jec()
    Dim Numbers(7), it
    For Each it In Array(1, 3, 5, 9, 10, 20, 25, 26)
      Numbers(x) = Chr(64 + it): x = x + 1
    Next
    End Sub
    If you have over 26 columns, use the method Sintek provided

    Sub jec()
    Dim Numbers(7), it
    For Each it In Array(1, 3, 5, 9, 10, 20, 25, 27)
      Numbers(x) = Split(Cells(1, it).Address, "$")(1): x = x + 1
    Next
    End Sub
    Last edited by JEC.; 01-07-2022 at 09:21 AM.

  8. #8
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: How Convert number to letter more that 1 number ?

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. Posting code between [code] [/code] tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (Note: this change is not optional. No help to be offered until this moderation request has been fulfilled.)

    I realise you have already had several replies. HOWEVER, no FURTHER help to be offered until this requiremtn has been complied with.
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU

+ 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] Convert a number to a letter?
    By RustyNail in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-02-2019, 09:16 AM
  2. [SOLVED] Convert Letter to Number then add together
    By d3vious in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-16-2016, 10:26 AM
  3. how to convert letter to number .
    By choy96 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 09-12-2014, 04:08 AM
  4. Convert number into letter, it is possible?
    By Exxcel Noob in forum Excel General
    Replies: 7
    Last Post: 05-02-2012, 05:24 PM
  5. Excel 2007 : Convert a letter to a number
    By CamnJane in forum Excel General
    Replies: 3
    Last Post: 10-25-2011, 10:52 PM
  6. Convert letter to Number
    By gtmeloney in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-23-2009, 11:10 AM
  7. How do I convert a given number into a letter?
    By vortex0001 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 09-08-2005, 06: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