There are a couple of ways of selecting the sheets.
Either using the Replace argument or by building an array of sheetnames.
Private Sub SelectSheets_Click()
Dim blnReplace As Boolean
Dim lngRow As Long
blnReplace = True
For lngRow = 3 To 21
If Cells(lngRow, 2) = "Y" Then
Sheets(Cells(lngRow, 1).Value).Select blnReplace
blnReplace = False
End If
Next
MsgBox "Using Replace"
Me.Select ' clear selection
Dim lngNSheets As Long
Dim lngCount As Long
lngNSheets = Application.WorksheetFunction.CountIf(Range("B3:B21"), "Y")
ReDim vntSheets(1 To lngNSheets) As Variant
For lngRow = 3 To 21
If Cells(lngRow, 2) = "Y" Then
lngCount = lngCount + 1
vntSheets(lngCount) = Cells(lngRow, 1)
End If
Next
Sheets(vntSheets).Select
MsgBox "Using array"
End Sub
Bookmarks