PDA

View Full Version : Solved: Make Workbook level event local



jmenche
10-19-2005, 05:17 AM
Howdy,

I was given this code for help on a workbook where every sheet had the same structure. I want to use this sub in another workbook where it is only needed in one sheet. Is there a way to localize this?

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
If Target.Row = 7 And Target.Column >= 2 And Target.Column <= 4 Then
Sh.Range("A7:E49").Sort Key1:=Target.Cells(1, 1), Order1:=xlAscending, Header:=xlYes
End If
End Sub

Killian
10-19-2005, 05:22 AM
Indeed there is...
In the project explorer, select the sheet you want to control and add the code to the Worksheet_SelectionChange event

jmenche
10-19-2005, 05:34 AM
Thanks!:)