ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Trigger Code with Mouse Click (https://www.excelbanter.com/excel-programming/289967-trigger-code-mouse-click.html)

Phil Hageman[_3_]

Trigger Code with Mouse Click
 
In this code, when the user highlights or mouse clicks on a trigger cell in the €śScorecard€ť worksheet, they are moved to one of four other worksheets, according to the schedule. Is there a way to restrict triggering this code to a mouse click only €“ eliminates triggering by simply arrowing to the trigger cell

Sub Worksheet_SelectionChange(ByVal Target As Excel.Range
Dim v(1 To 16, 1 To 3) As Strin
Dim rng1 As Rang
Dim i As Lon

v(1, 1) = "C12": v(1, 2) = "Customer": v(1, 3) = "A1
v(2, 1) = "E17": v(2, 2) = "Customer": v(2, 3) = "A1
v(3, 1) = "E20": v(3, 2) = "Customer": v(3, 3) = "A33
v(4, 1) = "E23": v(4, 2) = "Customer": v(4, 3) = "A65
v(5, 1) = "C30": v(5, 2) = "Financial": v(5, 3) = "A1
v(6, 1) = "E35": v(6, 2) = "Financial": v(6, 3) = "A1
v(7, 1) = "E38": v(7, 2) = "Financial": v(7, 3) = "A33
v(8, 1) = "E41": v(8, 2) = "Financial": v(8, 3) = "A65
v(9, 1) = "AC12": v(9, 2) = "Learning and Growth": v(9, 3) = "A1
v(10, 1) = "AE17": v(10, 2) = "Learning and Growth": v(10, 3) = "A1
v(11, 1) = "AE20": v(11, 2) = "Learning and Growth": v(11, 3) = "A33
v(12, 1) = "AE23": v(12, 2) = "Learning and Growth": v(12, 3) = "A65
v(13, 1) = "AC30": v(13, 2) = "Internal Business Process": v(13, 3) = "A1
v(14, 1) = "AE35": v(14, 2) = "Internal Business Process": v(14, 3) = "A1
v(15, 1) = "AE38": v(15, 2) = "Internal Business Process": v(15, 3) = "A33
v(16, 1) = "AE41": v(16, 2) = "Internal Business Process": v(16, 3) = "A65

For i = 1 To 1
If Target.Address = Range(v(i, 1)).MergeArea.Address The
Application.ScreenUpdating = Fals
Set rng1 = Sheets(v(i, 2)).Range(v(i, 3)
Sheets(v(i, 2)).Selec
rng1.Selec
ActiveWindow.Zoom = 6
ActiveWindow.ScrollRow = rng1.ro
ActiveWindow.ScrollColumn = rng1.Colum
Application.ScreenUpdating = Tru
Exit Fo
End I
Nex
End Su


Jim Rech

Trigger Code with Mouse Click
 
I think it's going to be tough to figure out how a range was selected. I
might be inclined to have users double-click a cell, and then use the
Worksheet_BeforeDoubleClick event.

Btw, it might be more efficient to make your array a public variable and
populate it just once, say during the Workbook_Open event, rather than every
time a cell is selected.

--
Jim Rech
Excel MVP




All times are GMT +1. The time now is 05:49 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com