Try to find worksheet by partial match

This commit is contained in:
updsv7
2026-04-13 12:28:31 +09:00
parent 30e2b8e5c3
commit 30afb491c4

View File

@@ -38,7 +38,19 @@ Sub FillFromKukanMaster(ByVal ws As Worksheet, ByVal rowNum As Long, Optional By
Dim code As String
On Error Resume Next
Set wsKukan = ThisWorkbook.Worksheets("区間メンテナンス")
' Try to find worksheet with partial match
Dim wsName As String
wsName = "区間メンテナンス"
Set wsKukan = Nothing
Dim s As Worksheet
For Each s In ThisWorkbook.Worksheets
If InStr(1, s.Name, "区間", vbTextCompare) > 0 Then
Set wsKukan = s
Exit For
End If
Next
If wsKukan Is Nothing Then Set wsKukan = ThisWorkbook.Worksheets(wsName)
If wsKukan Is Nothing Then
Dim wsList As String
Dim s As Worksheet