Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default R1C1 versus A1 in VB code

Debug.Print Selection.SpecialCells(xlCellTypeLastCell).Column produces a
column NUMBER.

How do I get back instead, or convert that to, the letter portion of the
column label in A1 format?

e.g. the last active cell is "Z42"

The above code returns 26. I need it to return "Z".

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default R1C1 versus A1 in VB code

I do the following:

dim iColumn as integer, sColumn as String
iColumn=26
sColumn = Chr(iColumn + 64)

"Bill Sturdevant" wrote:

Debug.Print Selection.SpecialCells(xlCellTypeLastCell).Column produces a
column NUMBER.

How do I get back instead, or convert that to, the letter portion of the
column label in A1 format?

e.g. the last active cell is "Z42"

The above code returns 26. I need it to return "Z".

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default R1C1 versus A1 in VB code

But, if the last column is "DJ", my code returns 114. The proposed solution
below does not handle that.

"Tony_VBACoder" wrote:

I do the following:

dim iColumn as integer, sColumn as String
iColumn=26
sColumn = Chr(iColumn + 64)

"Bill Sturdevant" wrote:

Debug.Print Selection.SpecialCells(xlCellTypeLastCell).Column produces a
column NUMBER.

How do I get back instead, or convert that to, the letter portion of the
column label in A1 format?

e.g. the last active cell is "Z42"

The above code returns 26. I need it to return "Z".

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 133
Default R1C1 versus A1 in VB code

try temp = ActiveCell.Address to get you started

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 184
Default R1C1 versus A1 in VB code

Hi Bill,
If you use:
Debug.Print Selection.SpecialCells(xlCellTypeLastCell).Address (False,
False)
It will return: A1

If you use:
Debug.Print Selection.SpecialCells(xlCellTypeLastCell).Address
It will return: $A$1

HTH--Lonnie M.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default R1C1 versus A1 in VB code

Thank you! We are almost there! What I am really trying to get is the "A"
in the "A1"!

"Lonnie M." wrote:

Hi Bill,
If you use:
Debug.Print Selection.SpecialCells(xlCellTypeLastCell).Address (False,
False)
It will return: A1

If you use:
Debug.Print Selection.SpecialCells(xlCellTypeLastCell).Address
It will return: $A$1

HTH--Lonnie M.


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
Question on this conversion code switching between r1c1 to A1 format tia sal2 temp Excel Worksheet Functions 1 September 16th 07 06:54 AM
Question on this conversion code switching between r1c1 to A1 format tia sal2 temp Excel Discussion (Misc queries) 2 September 14th 07 08:58 PM
R1C1 versus A1 Stuart Grant New Users to Excel 3 October 7th 05 05:30 PM
What's wrong with this code (r1c1 paste) mmattson Excel Programming 4 October 28th 04 07:37 AM
Converting code to R1C1 format Paul Excel Programming 1 April 15th 04 03:48 AM


All times are GMT +1. The time now is 09:52 AM.

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

About Us

"It's about Microsoft Excel"