Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default Multiple Target Addresses...

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 220
Default Multiple Target Addresses...

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Multiple Target Addresses...

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple values in Private Sub Worksheet_Change(ByVal Target As R davemon Excel Discussion (Misc queries) 2 September 21st 07 07:40 PM
More than one Target.Addresses AMY Z. Excel Programming 10 October 26th 06 04:50 PM
can 1 excel's DROP target change MULTIPLE cells? Huy Excel Programming 3 July 18th 06 09:04 AM
Multiple Target as Excel Range Mark Excel Programming 1 November 10th 04 10:46 AM
Consolidating multiple files into 1 target Mark[_26_] Excel Programming 1 September 27th 03 04:19 PM


All times are GMT +1. The time now is 10:56 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"