Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Specifically, I'm using a select...case statement in a Worksheet_change()
procedure to test which cell is being changed by the user. In this example you can see why my approach isn't suitable: Select Target.Address(false,false) Case "D9" to "D30" DoSomeStuff End Select Alphabetically "D30" occurs before "D9" so this test fails. I could test for each range individually like "D9","D10","D11",etc... but that's long and sloppy. There must be an easier way to test if a range is within or between another range? (BTW, I realize this won't work on a selection across multiple rows and columns. I have accounted for that.) TIA -Mike |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Mike,
Will this work? Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Intersect(Target,Range("D9:D30")) is Nothing then Exit Sub End If Do Something End Sub |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I believe it will. Thanks for helping me expand my VB vocabulary :D
"Ken Johnson" wrote in message oups.com... Hi Mike, Will this work? Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Intersect(Target,Range("D9:D30")) is Nothing then Exit Sub End If Do Something End Sub |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Mike,
Thanks for the feedback and you're welcome. I'm glad I could help. Ken Johnson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Test within a range? | Excel Worksheet Functions | |||
How I set up as logical test if my range has to be >=2 but <5 | Excel Discussion (Misc queries) | |||
Worksheet_Change and range test | Excel Programming | |||
== How to test if a range var contains nothing | Excel Programming | |||
how do i test for the existence of a range name | Excel Programming |