Excel - Return column alphabet from column number

S

Sathyaish

Is there some function in Excel (VBA) that will get me the column
alphabet if I provide the column number, or do I have to write one. I
ask because I know that there is, yet I recall I wrote this
functionality for the previous application, and I don't want to:

(1) Reuse it, if there's something in-built
(2) Re-invent the wheel

Help!

PS: I'm looking for something like:



code:--------------------------------------------------------------------------------
Function GetAlphabet(ByVal ColumnNumber as Long) as String
--------------------------------------------------------------------------------


which if I call must say:


code:--------------------------------------------------------------------------------
GetAlphabet(1)
 
T

Tom Ogilvy

activecell.Address

will give you row and column.

to get just the column

Left(activecell.Address(0,0), 1 +(-1*(activecell.Column > 26)))

or
Left(activecell.Address(0,0), 2 + (activecell.Column <= 26))
 
C

Chip Pearson

Try a function like the following:

Function ColLetter(ColNumber As Integer) As String
ColLetter = Left(Cells(1, ColNumber).Address(False, False), _
1 - (ColNumber > 26))
End Function


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top