Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$A$6" Then Run "Run_Print1" ElseIf Target.Address = "$A$7" Then Run "Run_Macro1" End If End Sub Well, the above code works well but I need to have the two macros it runs depending on the cell selected, be activated by a few more cell selections in each case. So, where I now only have cell selection A6, I also need to have A47, A88, A129, A170, and A211 selected cells activate the '"Run_Print1"' sequence. And, in addition to A7, I need A48, A89, A130, A171, and A212 for the 'Run_Macro1"' sequence to fire off. My thanks in advance for any ideas how best to tackle expanding the selections for Target.Address Brad |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Brad,
Try something like this: Select Case Target.Address Case "$A$6": ' Do something Case "$A$7": ' Do something Case "$A$47": ' Do something ' ... and so on ... End Select -- Dan |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
if Target.Count 1 then exit sub If Not Intersect(Target,Range( _ "A6,A47,A88,A129,A170,A211")) is nothing Then Run_Print1 ElseIf Not Intersect(Target,Range( _ "A7,A48,A89,A130,A171,A212 ")) is nothing Then Run_Macro1 End If End Sub or Private Sub Worksheet_SelectionChange(ByVal Target As Range) Select Case Target.Address(0,0) Case "A6", "A47", "A88", "A129", "A170", "A211" Run_Print1 Case "A7", "A48", "A89", "A130", "A171", "A212" Run_Macro1 End Select End Sub -- Regards, Tom Ogilvy "Brad" wrote: Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Address = "$A$6" Then Run "Run_Print1" ElseIf Target.Address = "$A$7" Then Run "Run_Macro1" End If End Sub Well, the above code works well but I need to have the two macros it runs depending on the cell selected, be activated by a few more cell selections in each case. So, where I now only have cell selection A6, I also need to have A47, A88, A129, A170, and A211 selected cells activate the '"Run_Print1"' sequence. And, in addition to A7, I need A48, A89, A130, A171, and A212 for the 'Run_Macro1"' sequence to fire off. My thanks in advance for any ideas how best to tackle expanding the selections for Target.Address Brad |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Multiple values in Private Sub Worksheet_Change(ByVal Target As R | Excel Discussion (Misc queries) | |||
More than one Target.Addresses | Excel Programming | |||
can 1 excel's DROP target change MULTIPLE cells? | Excel Programming | |||
Multiple Target as Excel Range | Excel Programming | |||
Consolidating multiple files into 1 target | Excel Programming |