Column number in letters

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
 
F

Frank Kabel

Hi
one way (in vBA):
msgbox
mid(cells(1,col_index).address,2,instr(2,cells(1,col_index).address,"$"
)-2)
 
R

Rob van Gelder

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
 
D

Dana DeLouis

One of a few other options:

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

Soo Cheon Jheong

Hi

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


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