Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
What is the function of
If Target.Cells.Count 1 then Exit sub End If and is it necessary as the first test in a Worksheet_Change(ByValue as Range) sub? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
This is to make sure that no action is taken if the user changes several
cells at once. -- Gary''s Student - gsnu200764 "Rick" wrote: What is the function of If Target.Cells.Count 1 then Exit sub End If and is it necessary as the first test in a Worksheet_Change(ByValue as Range) sub? |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
It is used to test whether more than one cell is being changed in one go,
and exits if so. It isn't necessary, it is a choice. You could cater for multiple cells, and process each one in a loop. -- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "Rick" wrote in message ... What is the function of If Target.Cells.Count 1 then Exit sub End If and is it necessary as the first test in a Worksheet_Change(ByValue as Range) sub? |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Jan 7, 4:06*pm, Rick wrote:
What is the function of * If Target.Cells.Count 1 then * * *Exit sub * End If and is it necessary as the first test in a Worksheet_Change(ByValue as Range) sub? * * * * * * * Hi Depends what you are doing. If you want the worksheet_change to trigger when the value in one cell changes, then you need to check that more than one cell did not change i.e. other cells you are not bothered about. quite often you will see if intersect(myRange, Target).Count1 then Exit Sub End if so you only want one cell within the range myRange to trigger the change (note .Cells is not required) You will also see variants of Set Testrange = intersect(myRange, Target) if not Testrange is nothing then if Testrange.count = 1 then 'do something else Exit Sub end If End if So you are checking that Target is within a certain range AND that it is only one cell, before change is triggered. Target can be more than one cell though (e.g. a sum of cell values reaching a value triggers change). regards Paul |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Target cell reference moves when target is cut and pasted | Excel Discussion (Misc queries) | |||
If target.count 1 | Excel Programming | |||
count the # of entries when sum matches the target | Excel Worksheet Functions | |||
Ranges:Target in Worksheet_SelectionChange(ByVal Target As Range) | Excel Programming | |||
Help - loop through cells in a range that are not together (several different cells as Target) | Excel Programming |