Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
J@Y J@Y is offline
external usenet poster
 
Posts: 127
Default Find the last cell in a selected range?

I have a user selecting a range, how would I put the ending cell in the range
in a variable?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Find the last cell in a selected range?

dim rng as range

set rng = selection.cells(selection.cells.count)

RBS


"J@Y" wrote in message
...
I have a user selecting a range, how would I put the ending cell in the
range
in a variable?


  #3   Report Post  
Posted to microsoft.public.excel.programming
J@Y J@Y is offline
external usenet poster
 
Posts: 127
Default Find the last cell in a selected range?

I guess there's no function for it because End(xldown) only goes to the first
blank cell. Thanks for the smart solution

"RB Smissaert" wrote:

dim rng as range

set rng = selection.cells(selection.cells.count)

RBS


"J@Y" wrote in message
...
I have a user selecting a range, how would I put the ending cell in the
range
in a variable?



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Find the last cell in a selected range?

Note that the code will not work if there are multiple areas selected. In that case:

Dim rng As Range
Set rng =
Selection.Areas(Selection.Areas.Count).Cells(Selec tion.Areas(Selection.Areas.Count).Cells.Count)

HTH,
Bernie
MS Excel MVP


"RB Smissaert" wrote in message
...
dim rng as range

set rng = selection.cells(selection.cells.count)

RBS


"J@Y" wrote in message
...
I have a user selecting a range, how would I put the ending cell in the range
in a variable?




  #5   Report Post  
Posted to microsoft.public.excel.programming
J@Y J@Y is offline
external usenet poster
 
Posts: 127
Default Find the last cell in a selected range?

Thanks for the note.

"Bernie Deitrick" wrote:

Note that the code will not work if there are multiple areas selected. In that case:

Dim rng As Range
Set rng =
Selection.Areas(Selection.Areas.Count).Cells(Selec tion.Areas(Selection.Areas.Count).Cells.Count)

HTH,
Bernie
MS Excel MVP


"RB Smissaert" wrote in message
...
dim rng as range

set rng = selection.cells(selection.cells.count)

RBS


"J@Y" wrote in message
...
I have a user selecting a range, how would I put the ending cell in the range
in a variable?







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Find the last cell in a selected range?

an additional note/added caution is that that method isn't reliable: (to
illustrate from the immediate window).

Set rng =
Selection.Areas(Selection.Areas.Count).Cells(Selec tion.Areas(Selection.Areas.Count).Cells.Count)
? rng.Address
$D$17
? selection.Address
$F$18:$G$21,$C$10:$E$14,$D$16:$D$17


I would have expected G21 to be the result. It depends on how the user
selects the range.

--
Regards,
Tom Ogilvy


"J@Y" wrote:

Thanks for the note.

"Bernie Deitrick" wrote:

Note that the code will not work if there are multiple areas selected. In that case:

Dim rng As Range
Set rng =
Selection.Areas(Selection.Areas.Count).Cells(Selec tion.Areas(Selection.Areas.Count).Cells.Count)

HTH,
Bernie
MS Excel MVP


"RB Smissaert" wrote in message
...
dim rng as range

set rng = selection.cells(selection.cells.count)

RBS


"J@Y" wrote in message
...
I have a user selecting a range, how would I put the ending cell in the range
in a variable?




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Find the last cell in a selected range?

Check your previous post, too.

J@Y wrote:

I have a user selecting a range, how would I put the ending cell in the range
in a variable?


--

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
Find last row and column in a selected range Bernie Deitrick Excel Programming 0 December 20th 06 02:41 PM
Macro to find empty cell and select range to print selected. [email protected] Excel Programming 1 May 15th 06 09:05 AM
Find Findnext in selected range looloo[_2_] Excel Programming 2 January 25th 05 06:51 PM
how to find last row/col index within a selected range Jeff Excel Programming 2 October 6th 04 03:58 PM
VB code to find the selected cell Andrew[_22_] Excel Programming 2 September 9th 03 06:29 AM


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