Function fncCheckSheetTitles(wst As Worksheet) As Boolean
Dim expectedTitles As Variant
Dim actualTitle As String
Dim i As Integer
On Error GoTo ErrorHandler
' 期待するタイトルを配列に格納
expectedTitles = Array("項目A", "項目B", "項目C")
' A1, B1, C1セルの値をチェック
For i = LBound(expectedTitles) To UBound(expectedTitles)
actualTitle = wst.Cells(1, i + 1).Value ' 1行目のセルを順に取得
If actualTitle <> expectedTitles(i) Then
fncCheckSheetTitles = False
Exit Function
End If
Next i
fncCheckSheetTitles = True
Exit Function
ErrorHandler:
MsgBox "エラーが発生しました: " & Err.Description, vbCritical
fncCheckSheetTitles = False
End Function
コメント