ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Test if ActiveCell is within a certain named range (https://www.excelbanter.com/excel-programming/355453-test-if-activecell-within-certain-named-range.html)

steven

Test if ActiveCell is within a certain named range
 
I have a range named "RangePriority". When I click in a cell in the
worksheet how can I test to see if it is within the range "RangePriority".

I guess it the testing would occur in:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Code Here to Test ActiveCell
End Sub

Thank you for your help.

Steven

Ardus Petus

Test if ActiveCell is within a certain named range
 
if intersect(Target, Range("RangePriority") then
do something
end if

HTH
--
AP

"Steven" a écrit dans le message de
...
I have a range named "RangePriority". When I click in a cell in the
worksheet how can I test to see if it is within the range "RangePriority".

I guess it the testing would occur in:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Code Here to Test ActiveCell
End Sub

Thank you for your help.

Steven




Norman Jones

Test if ActiveCell is within a certain named range
 
Hi Steven,

Try:

'=============
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Not Intersect(Range("RangePriority"), Target) Is Nothing Then
MsgBox Target.Address(0, 0) _
& " intersects with the RangePriority range"
End If

End Sub
'<<=============



---
Regards,
Norman



"Steven" wrote in message
...
I have a range named "RangePriority". When I click in a cell in the
worksheet how can I test to see if it is within the range "RangePriority".

I guess it the testing would occur in:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Code Here to Test ActiveCell
End Sub

Thank you for your help.

Steven





All times are GMT +1. The time now is 03:13 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com