Here's my attempt using Select Case - though I'd prefer KazJaw's If/ElseIf, as it is even more flexible.
Dim z as Integer For Each s in myReport.Sheets Select Case UCase(s.Name) Case "DATA": z = 80 Case "DEFINITIONS": z = 75 Case "SUMMARY": z = 71 Case Else: If Left(s.Name, 7) = "Charts_" Then z = 77 Else z = 0 End If End Select If z Then s.Activate ActiveWindow.Zoom = z End If Next s
Alternatively, you can create a very flexible Select Case statement with the following trick:
For Each s In ThisWorkbook.Sheets Select Case True Case s.Name = "Data": z = 80 Case Left(s.Name, 7) = "Charts_": z = 77 Case s.Name = "Defintions": z = 75 Case s.Name = "Summary": z = 71 Case Else: z = 0 End Select If z Then s.Activate ActiveWindow.Zoom = z End If Next s
As you can see from the two examples, the first Select Case allows you to execute a central code for each comparison (e.g. the UCase, which is a good practise anyway), while the second gives you full flexibility - but is in the end nothing else then an If/ElseIf/... statement!