Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I need to write a procedure that will run only when a selected cell is within
a range of cells. How do I identify if it is within a range? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Use intersect
Worksheets("Sheet1").Activate Set isect = Application.Intersect(Range("rg1"), Range("rg2")) If isect Is Nothing Then MsgBox "Ranges do not intersect" Else isect.Select End If "ranswert" wrote: I need to write a procedure that will run only when a selected cell is within a range of cells. How do I identify if it is within a range? |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks I 'll give that a try
"Joel" wrote: Use intersect Worksheets("Sheet1").Activate Set isect = Application.Intersect(Range("rg1"), Range("rg2")) If isect Is Nothing Then MsgBox "Ranges do not intersect" Else isect.Select End If "ranswert" wrote: I need to write a procedure that will run only when a selected cell is within a range of cells. How do I identify if it is within a range? |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
If not intersect(Selection, myRange) is nothing then 'do something end if where myRange is your Range of Cells. e.g. Set myRange = ActiveSheet.Range("A2:B6") If you only want one cell selected then If Selection.Count = 1 then If not intersect(Selection, myRange) is nothing then 'do something end If End If regards Paul On Feb 4, 3:04*pm, ranswert wrote: I need to write a procedure that will run only when a selected cell is within a range of cells. *How do I identify if it is within a range? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
NEED VBA TO SELECT A CELL; NOTE THE CELL VALUE;COPYADJ CELL;FIND CELL VALUE IN A RANGE AND SO ON | Excel Programming | |||
Determine if range has NO Blank Cells without looping through each cell in range | Excel Programming | |||
Selecting range in list of range names depending on a cell informa | Excel Discussion (Misc queries) | |||
Change cell colour for a cell or range within a predefined range | Excel Programming | |||
Range.Find returns cell outside of range when range set to single cell | Excel Programming |