View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Placement of Code

Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Dim v(1 To 12, 1 To 3) As String
Dim rng1 As Range
Dim i As Long
v(1, 1) = "E17": v(1, 2) = "Customer": v(1, 3) = "A1"
v(2, 1) = "E20": v(2, 2) = "Customer": v(2, 3) = "A33"
v(3, 1) = "E23": v(3, 2) = "Customer": v(3, 3) = "A65"
v(4, 1) = "E35": v(4, 2) = "Financial": v(4, 3) = "A1"
v(5, 1) = "E38": v(5, 2) = "Financial": v(5, 3) = "A33"
v(6, 1) = "E41": v(6, 2) = "Financial": v(6, 3) = "A65"
v(7, 1) = "AE17": v(7, 2) = "Learning": v(7, 3) = "A1"
v(8, 1) = "AE20": v(8, 2) = "Learning": v(8, 3) = "A33"
v(9, 1) = "AE23": v(9, 2) = "Learning": v(9, 3) = "A65"
v(10, 1) = "AE35": v(10, 2) = "Process": v(10, 3) = "A1"
v(11, 1) = "AE38": v(11, 2) = "Process": v(11, 2) = "A33"
v(12, 1) = "AE41": v(12, 2) = "Process": v(12, 3) = "A65"


For i = 1 To 12
If Target.Address = Range(v(i, 1)).MergeArea.Address Then
Application.ScreenUpdating = False
Set rng1 = Sheets(v(i, 2)).Range(v(i, 3))
Sheets(v(i, 2)).Select
rng1.Select
ActiveWindow.Zoom = 62
ActiveWindow.ScrollRow = rng1.Row
ActiveWindow.ScrollColumn = rng1.Column
Application.ScreenUpdating = True
Exit For
End If
Next
End Sub

--
Regards,
Tom Ogilvy

"Phil Hageman" wrote in message
...
Thanks, Tom - it works perfectly. I want to expand this to include other

"click cells" (the merged cell range being clicked on ) and worksheet target
cells. Should I create this sub for each click cell, or could the existing
code include all the addresses, as follows:

Click Cell Target W/S and Cell
E17 Customer A1
E20 Customer A33 existing code does this case
E23 Customer A65
E35 Financial A1
E38 Financial A33
E41 Financial A65
AE17 Learning A1
AE20 Learning A33
AE23 Learning A65
AE35 Process A1
AE38 Process A33
AE41 Process A65

Thanks, Phil