Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Determining end of user-selected range

Let's say a user selects ranges A4:A10. In VBA, how can I find out where
the range is ending (i.e. "A10")?

I'm trying to write code that lets the user delete rows within certain
boundaries, so I need to know if the user has selected a range that falls
partially out of bounds -- for instance, he/she can only delete rows within
A4:A8, so I need to trap if he/she selects outside A8 and give an error
message.

How do I detect the end of the user-selected range?

Thanks.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Determining end of user-selected range

Syed,

Selection.SpecialCells(xlCellTypeLastCell).Address

Neil

"Syed Faisal" wrote in message
...
Let's say a user selects ranges A4:A10. In VBA, how can I find out where
the range is ending (i.e. "A10")?

I'm trying to write code that lets the user delete rows within certain
boundaries, so I need to know if the user has selected a range that falls
partially out of bounds -- for instance, he/she can only delete rows

within
A4:A8, so I need to trap if he/she selects outside A8 and give an error
message.

How do I detect the end of the user-selected range?

Thanks.




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Determining end of user-selected range

Sub Tester11()
Dim rng As Range, rng1 As Range
Set rng = Selection
If rng.Areas.Count = 1 Then
Set rng1 = rng(rng.Count)
MsgBox rng1.Address
End If

End Sub


But, your test might be

set rng = Range("A4:A8") 'allowed range
if union(selection,rng).Address < rng.Address then
msgbox "out of bounds"
End if


--
Regards,
Tom Ogilvy

"Syed Faisal" wrote in message
...
Let's say a user selects ranges A4:A10. In VBA, how can I find out where
the range is ending (i.e. "A10")?

I'm trying to write code that lets the user delete rows within certain
boundaries, so I need to know if the user has selected a range that falls
partially out of bounds -- for instance, he/she can only delete rows

within
A4:A8, so I need to trap if he/she selects outside A8 and give an error
message.

How do I detect the end of the user-selected range?

Thanks.




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
Determining Frequency of range Leitodd Excel Worksheet Functions 2 October 16th 09 03:03 AM
dynamic chart on user selected data range in Excel 2007 turen Charts and Charting in Excel 5 September 1st 07 02:03 AM
Determining if a chart is selected [email protected] Charts and Charting in Excel 2 January 25th 05 03:06 PM
Determining selected worksheet Bob Conar Excel Programming 3 October 20th 03 01:51 AM
Determining whether selected cell has value or formula? John Wirt Excel Programming 3 July 31st 03 04:19 AM


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