Hello again. Excel 2003
If I have a column number e.g. 4, is there an Excel method to convert this to the letter "D", or do I need
to add 4 to chr(65)-1? Thanks, Andy.
Get column letter
-
- SilverLounger
- Posts: 2403
- Joined: 05 Feb 2010, 22:21
- Location: London ENGLAND
Get column letter
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
-
- Administrator
- Posts: 78629
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Get column letter
I assume you want to do this in VBA.
Let's say the column number is stored in a variable n.
This will work whether the column has one letter (as for column D) or two (as for column DF) or even three (in Excel 2007 or higher, e.g. column DFG).
Let's say the column number is stored in a variable n.
Code: Select all
Dim n As Long
Dim strAddress As String
Dim p As Long
Dim strColumn As String
n = ...
strAddress = Cells(1, n).Address(RowAbsolute:=True, ColumnAbsolute:=False)
p = InStr(strAddress, "$")
strColumn = Left(strAddress, p - 1)
Best wishes,
Hans
Hans
-
- SilverLounger
- Posts: 2403
- Joined: 05 Feb 2010, 22:21
- Location: London ENGLAND
Re: Get column letter
Thanks again.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.