diff --git a/vba_code_kukan_detail_master.txt b/vba_code_kukan_detail_master.txt index f7803ee..c96076c 100644 --- a/vba_code_kukan_detail_master.txt +++ b/vba_code_kukan_detail_master.txt @@ -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