update Master_M1_Kukan

This commit is contained in:
updsv7
2026-04-15 17:05:17 +09:00
parent 20f04cd9bd
commit d32e339d52
2 changed files with 73 additions and 38 deletions

View File

@@ -6,10 +6,37 @@ Const END_COL As Long = 14 ' N column
Const ERROR_COL As Long = 15 ' O column
Private z1Cache As Object ' Z1 cache
Private enumCache As Object ' Z1 cache
' ====== Function ======
Public Sub RefreshZ1Cache()
On Error GoTo RefreshError
Set z1Cache = LoadLookup("Z1", keyCol:=3, valueCols:=Array(4), startRow:=7)
On Error GoTo 0
If z1Cache Is Nothing Or z1Cache.Count = 0 Then
Err.Raise 1001, "RefreshZ1Cache", "Z1 reference data is empty"
End If
Exit Sub
RefreshError:
Err.Raise 1002, "RefreshZ1Cache", "Failed to load Z1 lookup cache: " & Err.Description
End Sub
Public Sub RefreshEnumCache()
On Error GoTo RefreshError
Set tokubetuKbn = LoadLookup("Enum", keyCol:=3, valueCols:=Array(3), startRow:=3)
On Error GoTo 0
If tokubetuKbn Is Nothing Or tokubetuKbn.Count = 0 Then
Err.Raise 1003, "RefreshZ1Cache", "Enum reference data is empty"
End If
Exit Sub
RefreshError:
Err.Raise 1001, "RefreshZ1Cache", "Failed to load Z1 lookup cache: " & Err.Description
End Sub
' Get CSV header from row 5 (columns C to N)
@@ -170,7 +197,6 @@ Sub validate(ByVal rowNum As Long, ByVal lastDataRow As Long)
' Check D and E column in the cache
If z1Cache Is Nothing Then Call RefreshZ1Cache
If z1Cache Is Nothing Then Exit Sub
Dim dValue As String: dValue = Trim(ws.Range("D" & rowNum).Value)
Dim eValue As String: eValue = Trim(ws.Range("E" & rowNum).Value)
@@ -197,12 +223,21 @@ Sub validate(ByVal rowNum As Long, ByVal lastDataRow As Long)
End If
End If
' Check L column in the cache
If enumCache Is Nothing Then Call RefreshEnumCache
Dim lValue As String: lValue = Trim(ws.Range("L" & rowNum).Value)
If Not enumCache.Exists(lValue) Then
ws.Cells(rowNum, ERROR_COL).Value = "L column does not exist."
ws.Range("L" & rowNum).Interior.Color = RGB(255, 0, 0)
Exit Sub
End If
' Validation passed - clear error
ws.Cells(rowNum, ERROR_COL).ClearContents
End Sub
Sub validateButton()
' Validate button
Sub M1_validateButton()
Dim lastDataRow As Long, r As Long, errorCount As Long
lastDataRow = GetLastDataRowInRange(Me, START_COL, END_COL)
@@ -323,9 +358,9 @@ Sub M1_SortDataRowsByC()
End Sub
Sub M1_ToggleAutoFilter()
Call ToggleAutoFilter(3, 14)
Call ToggleAutoFilter(START_COL, END_COL)
End Sub
Sub M1_AutoFitColumnWidth()
Call AutoFitColumnWidth(3, 14)
Call AutoFitColumnWidth(START_COL, END_COL)
End Sub