Column number in letters

  • Thread starter Thread starter tich1234
  • Start date Start date
T

tich1234

I have a spreadsheet where the column number is dynamic, ie it change
based on a access query from which the spreadsheet is exported.

Can anybody tell me how to find the column letter(like A,B, C...AA, AB
if I know the coulm number(like 1,2,3...27,28).

In other words how do I find the column letter if I know the colum
number.

Thanks,

William
 
Hi
one way (in vBA):
msgbox
mid(cells(1,col_index).address,2,instr(2,cells(1,col_index).address,"$"
)-2)
 
I have an example on my website.

For archiving purposes:
Sub test()
Dim lngColumn As Long, strColumn As String

lngColumn = 27
strColumn = Split(Columns(lngColumn).Address(, False), ":")(1)
MsgBox strColumn
End Sub
 
One of a few other options:

n=26, or 27
ColumnLetter = Left$(Cells(n).Address(False, False), (n <= 26) + 2)
 
Hi

MsgBox Replace(Cells(1, col_index).Address(0, 0), 1, "")


--
Regards,
Soo Cheon Jheong
Seoul, Korea
_ _
^¢¯^
--
 

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

Back
Top