Sub WhereAreWe()
Dim rngAll As Excel.Range
Dim rngArea As Excel.Range
Dim blnOutside As Boolean
' Establish the boundaries...
Const rTop As Long = 10
Const rBott As Long = 100
Const cLeft As Long = 5
Const cRight As Long = 15
Set rngAll = Selection
For Each rngArea In rngAll.Areas
Select Case True
Case rngArea.Row < rTop
blnOutside = True
Case rngArea.Rows(rngArea.Rows.Count).Row > rBott
blnOutside = True
Case rngArea.Column < cLeft
blnOutside = True
Case rngArea.Columns(rngArea.Columns.Count).Column > cRight
blnOutside = True
End Select
If blnOutside Then
MsgBox "Oops"
Exit For
End If
Next
Set rngArea = Nothing
Set rngAll = Nothing
End Sub
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
"rockhammer"
<(E-Mail Removed)>
wrote in message
I am expecting the user to select 1 or more not necessarily contiguous cells
and then operate on those cells. But first, I want to check that all selected
cells are within a specified cell range, say, $a$11:$a$200. Two questions:
1) how do I loop thru the user selected cells?
2) is there a way to do that range check mentioned above without looping
thru the selected cells?
Thanks a lot.