+ Reply to Thread
Results 1 to 5 of 5

Convert Column Number to Alphabet

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    07-18-2012
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    192

    Convert Column Number to Alphabet

    Hi Friends

    I am using the below code to identify column number. However, it comes up with number and I want that to be in Alphabet (like column P etc).

    Can you please help how should I amend the below code?

    Sub Column()

    Dim FindCol As Range

    Set FindCol = Cells.Find(What:="May 16", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
    :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
    False, SearchFormat:=False)

    MsgBox FindCol.Column

    End Sub

    Thanks in advance

  2. #2
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,565

    Re: Convert Column Number to Alphabet

    Hi arpanpanchal,

    You can use the strFindCol variable from this:

    Option Explicit
    Sub MyColumn()
    
    Dim rngFindCol As Range
    Dim strFindCol As String
    
    Set rngFindCol = Cells.Find(What:="May 16", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
     :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
     False, SearchFormat:=False)
    
    MsgBox rngFindCol.Column
    
    strFindCol = Left(Cells(rngFindCol.Row, rngFindCol.Column).Address(True, False), Application.WorksheetFunction.Search("$", Cells(rngFindCol.Row, rngFindCol.Column).Address(True, False)) - 1)
    
    MsgBox strFindCol
    
    End Sub
    Note it will fail if no match is found.

    Please make sure you wrap your code with the appropriate tags as I have done.

    Regards,

    Robert
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

  3. #3
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: Convert Column Number to Alphabet

    Another way:
    Sub Column()
    
    Dim FindCol As Range
    
    Set FindCol = Cells.Find(What:="May 16", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
    :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
    False, SearchFormat:=False)
    
    MsgBox Replace(FindCol.Address(0, 0), FindCol.row, "")
    
    End Sub
    多么想要告诉你 我好喜欢你

  4. #4
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,522

    Re: Convert Column Number to Alphabet

    And another one.
    Sub MyColumn()
    
    Dim rngFindCol As Range
    
    Set rngFindCol = Cells.Find(What:="May 16", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
     :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
     False, SearchFormat:=False)
    
    MsgBox Split(rngFindCol.Address, "$")(1)
    
    End Sub
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  5. #5
    Forum Contributor
    Join Date
    07-18-2012
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    192

    Re: Convert Column Number to Alphabet

    Thanks a lot friends...It works perfect

    Thanks again

+ 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. Formula to convert number to alphabet
    By choy96 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 09-13-2014, 01:25 AM
  2. [SOLVED] Convert Interger number to column Alphabet
    By rizmomin in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-08-2014, 08:05 AM
  3. How do I obtain the column alphabet number if we know the row column number
    By ckb in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-01-2007, 11:42 AM
  4. [SOLVED] how to convert numeric into alphabet
    By fong in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-07-2005, 12:05 AM
  5. how to convert numeric into alphabet
    By fong in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 03:05 PM
  6. how to convert numeric into alphabet
    By Peo Sjoblom in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-06-2005, 05:05 AM
  7. [SOLVED] how to convert numeric into alphabet
    By fong in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 03: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