Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default Column index returned - how to get the Letter

x = ActiveCell.Column
Returns 1 for column A

How do I get x = A?

Hmmm

Arturo
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Column index returned - how to get the Letter

Arturo,

Function GetColumn(ByRef lngColumnNum As Long) As String
GetColumn = Application.Substitute(Cells(1, _
lngColumnNum).Address(False, False), "1", vbNullString)
End Function
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


"Arturo"
wrote in message
x = ActiveCell.Column
Returns 1 for column A
How do I get x = A?
Hmmm
Arturo
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Column index returned - how to get the Letter

One way:

Option Explicit
Function ColLetter(rng As Range) As String
Dim myStr As String
With rng.Parent
myStr = .Cells(1, rng.Column).Address(0, 0)
myStr = Left(myStr, Len(myStr) - 1)
End With
ColLetter = myStr
End Function

And I could test it with:
Sub testme()
MsgBox ColLetter(ActiveCell)
End Sub



Arturo wrote:

x = ActiveCell.Column
Returns 1 for column A

How do I get x = A?

Hmmm

Arturo


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default Column index returned - how to get the Letter

Thank you.

Dim arr As Variant
arr = Split(ActiveCell.Address, "$")
MsgBox arr(1)

"Dave Peterson" wrote:

One way:

Option Explicit
Function ColLetter(rng As Range) As String
Dim myStr As String
With rng.Parent
myStr = .Cells(1, rng.Column).Address(0, 0)
myStr = Left(myStr, Len(myStr) - 1)
End With
ColLetter = myStr
End Function

And I could test it with:
Sub testme()
MsgBox ColLetter(ActiveCell)
End Sub



Arturo wrote:

x = ActiveCell.Column
Returns 1 for column A

How do I get x = A?

Hmmm

Arturo


--

Dave Peterson

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default Column index returned - how to get the Letter

thanks.

Dim arr As Variant
arr = Split(ActiveCell.Address, "$")
MsgBox arr(1)


"Jim Cone" wrote:

Arturo,

Function GetColumn(ByRef lngColumnNum As Long) As String
GetColumn = Application.Substitute(Cells(1, _
lngColumnNum).Address(False, False), "1", vbNullString)
End Function
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


"Arturo"
wrote in message
x = ActiveCell.Column
Returns 1 for column A
How do I get x = A?
Hmmm
Arturo



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Column index returned - how to get the Letter


That won't work in XL 97.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"Arturo"
wrote in message
thanks.
Dim arr As Variant
arr = Split(ActiveCell.Address, "$")
MsgBox arr(1)



"Jim Cone" wrote:
Arturo,
Function GetColumn(ByRef lngColumnNum As Long) As String
GetColumn = Application.Substitute(Cells(1, _
lngColumnNum).Address(False, False), "1", vbNullString)
End Function

--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware




"Arturo"
wrote in message
x = ActiveCell.Column
Returns 1 for column A
How do I get x = A?
Hmmm
Arturo

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Column index returned - how to get the Letter

Was this a test?

Arturo wrote:

Thank you.

Dim arr As Variant
arr = Split(ActiveCell.Address, "$")
MsgBox arr(1)

"Dave Peterson" wrote:

One way:

Option Explicit
Function ColLetter(rng As Range) As String
Dim myStr As String
With rng.Parent
myStr = .Cells(1, rng.Column).Address(0, 0)
myStr = Left(myStr, Len(myStr) - 1)
End With
ColLetter = myStr
End Function

And I could test it with:
Sub testme()
MsgBox ColLetter(ActiveCell)
End Sub



Arturo wrote:

x = ActiveCell.Column
Returns 1 for column A

How do I get x = A?

Hmmm

Arturo


--

Dave Peterson


--

Dave Peterson
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Column index returned - how to get the Letter

That would be the slowest way to do it. Enjoy.

--
Regards,
Tom Ogilvy


"Arturo" wrote in message
...
Thank you.

Dim arr As Variant
arr = Split(ActiveCell.Address, "$")
MsgBox arr(1)

"Dave Peterson" wrote:

One way:

Option Explicit
Function ColLetter(rng As Range) As String
Dim myStr As String
With rng.Parent
myStr = .Cells(1, rng.Column).Address(0, 0)
myStr = Left(myStr, Len(myStr) - 1)
End With
ColLetter = myStr
End Function

And I could test it with:
Sub testme()
MsgBox ColLetter(ActiveCell)
End Sub



Arturo wrote:

x = ActiveCell.Column
Returns 1 for column A

How do I get x = A?

Hmmm

Arturo


--

Dave Peterson



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Column letter to index Radon Excel Discussion (Misc queries) 3 February 2nd 09 05:29 AM
Translate Column Index Num to Letter DJS Excel Discussion (Misc queries) 8 December 8th 06 05:01 PM
How to replace column letter in refferences with a function using the old column letter? Dmitry Kopnichev Links and Linking in Excel 6 October 13th 05 09:09 AM
How to replace column letter in refferences with a function using the old column letter? Dmitry Kopnichev Excel Worksheet Functions 6 October 13th 05 09:09 AM
column header changed from letter to number, how return to letter Ron Excel Discussion (Misc queries) 2 May 9th 05 08:34 PM


All times are GMT +1. The time now is 07:24 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"