ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Column index name (https://www.excelbanter.com/excel-programming/319377-column-index-name.html)

John[_91_]

Column index name
 
Dear ALL,

I got a question that maybe a minor one to everyone. but anyway, if I know
the column number, how do I know what "alphabeth letter" refer to it? E.g.
I know the value c = 5 as referring column 5, but is there a way to return
the column letter "E" instead of 5? Please help since will need to use it
for setting formula inside macro. Many many thanks.

Regards,
John



Tom Ogilvy

Column index name
 
Range("Z21").Formula = "Sum(" & Cells(3,c).Resize(10,1).Address & ")"

Generally you don't need the column letter by itself.


However,

Left(columns(c).Address(0,0),1 + -1*(c 26))


from the immediate window:
c = 5
? Left(columns(c).Address(0,0),1 + -1*(c 26))
E
c = 27
? Left(columns(c).Address(0,0),1 + -1*(c 26))
AA

--
Regards,
Tom Ogilvy

"John" wrote in message
...
Dear ALL,

I got a question that maybe a minor one to everyone. but anyway, if I know
the column number, how do I know what "alphabeth letter" refer to it?

E.g.
I know the value c = 5 as referring column 5, but is there a way to return
the column letter "E" instead of 5? Please help since will need to use it
for setting formula inside macro. Many many thanks.

Regards,
John





JE McGimpsey

Column index name
 
You generally don't need to do this in a macro. instead of

Sheets("Sheet1").Range(Chr(64 + n) & "2").Formula = "=SUM(A1:B1)"

for instance, use

Sheets("Sheet1").Cells(2, n).Formula = "=SUM(A1:B1)"

or, if your range is in the formula:

Range("B1").Formula = _
"=SUM(" & Cells(2, n).Resize(10, 1).Address(0, 0) & ")"


In article ,
"John" wrote:

I got a question that maybe a minor one to everyone. but anyway, if I know
the column number, how do I know what "alphabeth letter" refer to it? E.g.
I know the value c = 5 as referring column 5, but is there a way to return
the column letter "E" instead of 5? Please help since will need to use it
for setting formula inside macro. Many many thanks.


Don Guillett[_4_]

Column index name
 
You don't need this for inside a macro
columns(3) is column C
range(cells(1,1),cells(1,3))

--
Don Guillett
SalesAid Software

"John" wrote in message
...
Dear ALL,

I got a question that maybe a minor one to everyone. but anyway, if I know
the column number, how do I know what "alphabeth letter" refer to it?

E.g.
I know the value c = 5 as referring column 5, but is there a way to return
the column letter "E" instead of 5? Please help since will need to use it
for setting formula inside macro. Many many thanks.

Regards,
John






All times are GMT +1. The time now is 10:26 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com