Private Sub CommandButton1_Click() Dim ShNM As String For i = 1 To 6 Sheets(1).Activate ShNM = Range("A" & i).Value If SheetExists Then Sheets(ShNM).Activate Else 'Nosheetのラベルの箇所に書いていた処理 End If 'Kyoutuuの所に書いていた処理 Next i End Sub
Function SheetExists(ByVal name As String) As Boolean Dim sh As Worksheet For Each sh In Sheets If sh.name = name Then SheetExists = True Exit Function End If Next SheetExists = False End Function