ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Common Private Sub (https://www.excelbanter.com/excel-discussion-misc-queries/55473-common-private-sub.html)

Booker

Common Private Sub
 
I have 25 same sheets and in everyone is included same Private Sub for cursor
movement.

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If Target.Address = "$G$8" Then
Range("C9").Select
End If
..
..
..
If Target.Address = "$D$32" Then
Range("I3").Select
End If
End Sub

How can I use this macro as one for all sheets to reduce size of file.

Thanks in advance.

Bob Phillips

Common Private Sub
 
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target
As Range)
If Target.Address = "$G$8" Then
Range("C9").Select
ElseIf Target.Address = "$D$32" Then
Range("I3").Select
End If
End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code



--

HTH

RP
(remove nothere from the email address if mailing direct)


"Booker" wrote in message
...
I have 25 same sheets and in everyone is included same Private Sub for

cursor
movement.

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If Target.Address = "$G$8" Then
Range("C9").Select
End If
.
.
.
If Target.Address = "$D$32" Then
Range("I3").Select
End If
End Sub

How can I use this macro as one for all sheets to reduce size of file.

Thanks in advance.





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

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