Add debug and error handling for C column trigger

This commit is contained in:
updsv7
2026-04-13 12:00:56 +09:00
parent 65ad779d6d
commit 61f6f31fce

View File

@@ -38,6 +38,7 @@ Private Sub Worksheet_Change(ByVal Target As Range)
If Trim(Target.Value) = "" Then If Trim(Target.Value) = "" Then
Call ClearRowData(Me, Target.Row) Call ClearRowData(Me, Target.Row)
Else Else
MsgBox "C column changed: " & Trim(Target.Value), vbInformation
Call FillFromKukanMaster(Me, Target.Row) Call FillFromKukanMaster(Me, Target.Row)
End If End If
End If End If
@@ -244,10 +245,13 @@ Sub FillFromKukanMaster(ByVal ws As Worksheet, ByVal rowNum As Long, Optional By
Dim deValue As String Dim deValue As String
Dim fgValue As String Dim fgValue As String
On Error Resume Next On Error GoTo 0
Set wsKukan = ThisWorkbook.Worksheets("区間メンテナンス") Set wsKukan = ThisWorkbook.Worksheets("区間メンテナンス")
If wsKukan Is Nothing Then Exit Sub If wsKukan Is Nothing Then
MsgBox "Worksheet '区間メンテナンス' not found.", vbExclamation
Exit Sub
End If
code = Trim(ws.Cells(rowNum, 3).Value) code = Trim(ws.Cells(rowNum, 3).Value)
If code = "" Then Exit Sub If code = "" Then Exit Sub
@@ -276,8 +280,7 @@ Sub FillFromKukanMaster(ByVal ws As Worksheet, ByVal rowNum As Long, Optional By
Next Next
If Not found Then If Not found Then
Call ClearRowData(ws, rowNum) MsgBox "Code '" & code & "' not found in 区間メンテナンス.", vbExclamation
Exit Sub
End If End If