Select sheet and default cell

JoeExcelHelp
5StarLounger
Posts: 1177
Joined: 22 Jul 2013, 18:29

Select sheet and default cell

Post by JoeExcelHelp »

Tried to modify this existing code that it only applies to sheets other than whats listed.. Thank You in advance for any assistance

Code: Select all

Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Dim Sht As Worksheet
For Each Sht In ActiveWorkbook.Worksheets
        Select Case Sht.Name
            Case "Schedule", "Hours", "Attrition", "Orientation", "Actuals", "ClassDist", "HiringPlan", "Data", "Data2", "Data3", "Data4", "Data5", "Data6"
                ' Ignore these sheets
            Case Else
        Sh.Range("G33").Select
        End Select
End Sub

User avatar
HansV
Administrator
Posts: 78631
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Select sheet and default cell

Post by HansV »

You don't need to loop through the sheets. The variable Sh is the sheet being activated.

Code: Select all

Private Sub Workbook_SheetActivate(ByVal Sh As Object)
    Select Case Sh.Name
        Case "Schedule", "Hours", "Attrition", "Orientation", "Actuals", "ClassDist", _
            "HiringPlan", "Data", "Data2", "Data3", "Data4", "Data5", "Data6"
            ' Ignore these sheets
        Case Else
            Sh.Range("G33").Select
    End Select
End Sub
Best wishes,
Hans

JoeExcelHelp
5StarLounger
Posts: 1177
Joined: 22 Jul 2013, 18:29

Re: Select sheet and default cell

Post by JoeExcelHelp »

Thank You Hans