Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Using Address in Range Definition??

Hi Folks,

Need some more help here.....Below is macro used to find the address of the
last cell in the last column used and store that address in variable "R"...

Sub lastcell()

Dim R As String

Cells(Rows.Count, "B").End(xlUp).Select
Selection.End(xlToRight).Select
R = Selection.Address
MsgBox (R)

End Sub

MsgBox will show the Address of the last cell. Assume last cell is H8,
Msgbox will display "$H$8".....This address is also stored in "R".

My question is how do I use the data stored in "R" in a Range
call....similar to the following...

Range("B4:R").Select

Thanks in advance,

Don

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Using Address in Range Definition??


Try this:

Range("B4:" & R).Select


--
renegan
------------------------------------------------------------------------
renegan's Profile: http://www.excelforum.com/member.php...o&userid=10450
View this thread: http://www.excelforum.com/showthread...hreadid=528773

  #3   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default Using Address in Range Definition??

Concatenate like you would any other string
Range("B4:"&R).Select

Also - just as a pointer, it is not usually necessary to select cells/ranges
in order to work with them. With larger macros, it can make a difference in
amount of time it takes to process.

Sub lastcell()
Dim R As String

R = Cells(Rows.Count, "B").End(xlUp).End(xlToRight).Address
MsgBox (R)

End Sub

"Don G" wrote:

Hi Folks,

Need some more help here.....Below is macro used to find the address of the
last cell in the last column used and store that address in variable "R"...

Sub lastcell()

Dim R As String

Cells(Rows.Count, "B").End(xlUp).Select
Selection.End(xlToRight).Select
R = Selection.Address
MsgBox (R)

End Sub

MsgBox will show the Address of the last cell. Assume last cell is H8,
Msgbox will display "$H$8".....This address is also stored in "R".

My question is how do I use the data stored in "R" in a Range
call....similar to the following...

Range("B4:R").Select

Thanks in advance,

Don

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Using Address in Range Definition??

Hi renegan,

Thank you very much for the quick reply....works like a charm.....:)

Don

"renegan" wrote:


Try this:

Range("B4:" & R).Select


--
renegan
------------------------------------------------------------------------
renegan's Profile: http://www.excelforum.com/member.php...o&userid=10450
View this thread: http://www.excelforum.com/showthread...hreadid=528773


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Using Address in Range Definition??

Hi JMB,

Thank you also for the very quick reply....and for the pointer.

Don

"JMB" wrote:

Concatenate like you would any other string
Range("B4:"&R).Select

Also - just as a pointer, it is not usually necessary to select cells/ranges
in order to work with them. With larger macros, it can make a difference in
amount of time it takes to process.

Sub lastcell()
Dim R As String

R = Cells(Rows.Count, "B").End(xlUp).End(xlToRight).Address
MsgBox (R)

End Sub

"Don G" wrote:

Hi Folks,

Need some more help here.....Below is macro used to find the address of the
last cell in the last column used and store that address in variable "R"...

Sub lastcell()

Dim R As String

Cells(Rows.Count, "B").End(xlUp).Select
Selection.End(xlToRight).Select
R = Selection.Address
MsgBox (R)

End Sub

MsgBox will show the Address of the last cell. Assume last cell is H8,
Msgbox will display "$H$8".....This address is also stored in "R".

My question is how do I use the data stored in "R" in a Range
call....similar to the following...

Range("B4:R").Select

Thanks in advance,

Don

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
definition of the range containing content Martin Excel Programming 2 November 22nd 05 01:35 PM
Range Definition in Macro ? Baapi Excel Programming 1 September 23rd 05 12:08 AM
Range definition problem Peter Chatterton[_2_] Excel Programming 6 November 18th 04 08:05 PM
How come this range definition is invalid? keepITcool Excel Programming 1 June 21st 04 07:15 PM
Using Cells( ) for Range definition [email protected] Excel Programming 5 September 2nd 03 08:04 PM


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