Column number to column name

newapa

Board Regular
Joined
Sep 13, 2012
Messages
69
Hi!

i got an vba code from a excel and it calculate out the column number and change it to column name.
but it just 2 chars. in excel we got column name like 3 chars.

example 1 char is only A. 2 char AA and 3 is AAA

i wonder some one can help me with the third char?

here's the formula
Code:
A =      =CHAR(COLUMN() + 64)
AA =    =IF(COLUMN()>26;CHAR(ROUNDDOWN((COLUMN()-1)/26;0)+64)&CHAR(MOD((COLUMN()-1);26)+65);CHAR(COLUMN()+64))
AAA =   ????

and here is the vba code

Code:
    If iCol <= 26 Then
        sColumn = Chr$(64 + iCol)
    ElseIf iCol <= 27*26 Then
        sColumn = Chr$((iCol - 1) \ 26 + 64) & Chr$((iCol - 1) Mod 26 + 65)
    Else
        sColumn = ???
    End If

i need it in formula and code

any help is appreciated
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
formula:
Excel Workbook
EF
2256
3
4IV
5E
Sheet


The same formula in both cells, just examples, one refers to cell F2 for the column number, the other to the column that the formula is in.
 
Upvote 0

Forum statistics

Threads
1,216,075
Messages
6,128,665
Members
449,462
Latest member
Chislobog

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top