Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default character representation of specific column

Dear all,

Is there a simple way in VBA to get the character representation of specific
column? For example, activesheet.cells(1, 2) = row = 1, column = "B" I guess
using chr(activesheet.cells(1, 2).column + 64) could do the job from "A" to
"Z". How about "AA"...?

Thanks in advance!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default character representation of specific column

================================================== =
' Jun 08, 2002 - Created - Thanks to Chip Pearson
' Jim Cone - San Francisco, USA
' Returns the address of the column from the provided column number.
'================================================= ==
Function GetColumnLetters(ByVal ColumnNum As Long) As String
On Error GoTo NoColumn
Dim ColChars As String
ColChars = Columns(ColumnNum).Address(False, False)
GetColumnLetters = Left$(ColChars, 2 + CBool(ColumnNum < 27)) '2 + 0 or 2 + (-1)
Exit Function

NoColumn:
Beep
GetColumnLetters = vbNullString
End Function
'================================================= ==



"KS Wong" wrote in message
...
Dear all,

Is there a simple way in VBA to get the character representation of specific
column? For example, activesheet.cells(1, 2) = row = 1, column = "B" I guess
using chr(activesheet.cells(1, 2).column + 64) could do the job from "A" to
"Z". How about "AA"...?

Thanks in advance!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default character representation of specific column

Thanks a lot, Jim

"Jim Cone" wrote:

================================================== =
' Jun 08, 2002 - Created - Thanks to Chip Pearson
' Jim Cone - San Francisco, USA
' Returns the address of the column from the provided column number.
'================================================= ==
Function GetColumnLetters(ByVal ColumnNum As Long) As String
On Error GoTo NoColumn
Dim ColChars As String
ColChars = Columns(ColumnNum).Address(False, False)
GetColumnLetters = Left$(ColChars, 2 + CBool(ColumnNum < 27)) '2 + 0 or 2 + (-1)
Exit Function

NoColumn:
Beep
GetColumnLetters = vbNullString
End Function
'================================================= ==



"KS Wong" wrote in message
...
Dear all,

Is there a simple way in VBA to get the character representation of specific
column? For example, activesheet.cells(1, 2) = row = 1, column = "B" I guess
using chr(activesheet.cells(1, 2).column + 64) could do the job from "A" to
"Z". How about "AA"...?

Thanks in advance!


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
Extracting characters before or after a specific character Brian Excel Worksheet Functions 4 April 27th 23 07:42 PM
Filter with a specific character pgarcia Excel Discussion (Misc queries) 2 January 12th 10 03:59 PM
Counting a Specific Character FARAZ QURESHI Excel Discussion (Misc queries) 2 April 27th 09 11:07 AM
How I find specific character?? TotallyConfused Excel Worksheet Functions 2 September 15th 08 07:56 AM
Counting Specific Character(s) In A Range? FARAZ QURESHI Excel Discussion (Misc queries) 10 September 14th 07 04:32 AM


All times are GMT +1. The time now is 06:29 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"