💻
ExcelVBAでシートの存在を確認する
特定のシートが存在するか確認するFunctionプロシージャ
'特定のシートがあるか検索
'返り値はBoolean
Private Function F_SearchOneSheet(ByVal arg_SheetName As String) As Boolean
Dim checkSheet As Worksheet
For Each checkSheet In Sheets
If checkSheet.Name = arg_SheetName Then
F_SearchOneSheet = True
Exit Function
End If
Next
F_SearchOneSheet = False
End Function
特定のシートが存在するか確認するFunctionプロシージャを呼び出す
Sub S_Main()
Dim searchSheetName As String
Dim hasOneSheet As Boolean
searchSheetName = "探したいシート名"
hasOneSheet = F_SearchOneSheet(searchSheetName)
End Sub
'特定のシートがあるか検索
'返り値はBoolean
Private Function F_SearchOneSheet(ByVal arg_SheetName As String) As Boolean
Dim checkSheet As Worksheet
For Each checkSheet In Sheets
If checkSheet.Name = arg_SheetName Then
F_SearchOneSheet = True
Exit Function
End If
Next
F_SearchOneSheet = False
End Function
Discussion