This commit is contained in:
updsv7
2026-04-21 19:15:10 +09:00
parent e2e115b7f4
commit 3ed46c8f7c
7 changed files with 67 additions and 14 deletions

View File

@@ -21,7 +21,7 @@ Private Sub Worksheet_Change(ByVal Target As Range)
End If
End Sub
Private Sub FillFromM1(ByVal rowNum As Long, Optional ByVal setG As Boolean = True)
Private Sub FillFromM1(ByVal rowNum As Long)
Set ws = Me
Dim m1Cache As Object: Set m1Cache = GetM1Cache()
@@ -36,15 +36,18 @@ Private Sub FillFromM1(ByVal rowNum As Long, Optional ByVal setG As Boolean = Tr
' Check C column in the cache
If Not m1Cache.Exists(cValue) Then
ws.Cells(rowNum, ERROR_COL).Value = "C column does not exist in M1."
ws.Range("C" & rowNum).Interior.Color = RGB(255, 0, 0)
ws.Cells(rowNum, 4).Value = ""
ws.Cells(rowNum, 5).Value = ""
ws.Cells(rowNum, 6).Value = ""
ws.Cells(rowNum, 7).Value = ""
ws.Cells(rowNum, 8).Value = ""
Exit Sub
End If
Dim cacheVal As Variant: cacheVal = m1Cache(cValue)
' D column = cache[1]: cache[2]
ws.Cells(rowNum, 4).Value = Trim(cacheVal(1)) & ": " & Trim(cacheVal(2))
ws.Cells(rowNum, 4).Value = Trim(cacheVal(1)) & ":" & Trim(cacheVal(2))
' E column = cache[3]
ws.Cells(rowNum, 5).Value = Trim(cacheVal(3))
' F column = cache[4]
@@ -76,19 +79,23 @@ Public Sub Validate(ws As Worksheet, ByVal rowNum As Long, ByVal lastDataRow As
' Check C column in the cache
Dim m1Cache As Object: Set m1Cache = GetM1Cache()
Dim cValue As String: cValue = Trim(ws.Range("C" & rowNum).Value)
If cValue <> "" AND Not m1Cache.Exists(cValue) Then
ws.Cells(rowNum, errorCol).Value = "C column does not exist in M1."
' C column check
checkResult = CheckRequired(ws, rowNum, 3, errorCol)
If checkResult = False Then Exit Sub
Dim cValue As String: cValue = Trim(ws.Range("C" & rowNum).Value)
If Not m1Cache.Exists(cValue) Then
ws.Cells(rowNum, errorCol).Value = GetErrorMsg("E004", "C" & rowNum)
ws.Range("C" & rowNum).Interior.Color = RGB(255, 0, 0)
Exit Sub
End If
' Check column required
Dim colLetter As Variant
For Each colLetter In Array("C", "I", "J", "K")
For Each colLetter In Array("I", "J", "K")
If Trim(ws.Range(colLetter & rowNum).Value) = "" Then
ws.Cells(rowNum, errorCol).Value = colLetter & " column is required"
ws.Cells(rowNum, errorCol).Value = GetErrorMsg("E002", colLetter & rowNum)
ws.Range(colLetter & rowNum).Interior.Color = RGB(255, 0, 0)
Exit Sub
End If
@@ -100,19 +107,24 @@ Public Sub Validate(ws As Worksheet, ByVal rowNum As Long, ByVal lastDataRow As
For Each col In numericCols
Dim val As String: val = Trim(ws.Range(col & rowNum).Value & "")
If val <> "" And Not IsNumeric(val) Then
ws.Cells(rowNum, errorCol).Value = col & " column must be numeric"
ws.Cells(rowNum, errorCol).Value = GetErrorMsg("E011", col & rowNum)
ws.Range(col & rowNum).Interior.Color = RGB(255, 0, 0)
Exit Sub
End If
Next col
' Check I column in the kenshuKbn
Dim kenshuKbn As Variant: kenshuKbn = Array("1", "2", "3")
Dim iValue As String: iValue = Trim(ws.Range("I" & rowNum).Value)
If UBound(Filter(kenshuKbn, iValue)) = -1 Then
ws.Cells(rowNum, errorCol).Value = "I column (kenshuKbn) must be 1, 2, or 3"
Dim kenshuList As Object: Set kenshuList = GetKenshuList()
Dim kenshuKbn As String: kenshuKbn = Trim(ws.Range("I" & rowNum).Value)
If Not kenshuList.Exists(kenshuKbn) Then
ws.Cells(rowNum, errorCol).Value = GetErrorMsg("E012", "I" & rowNum)
ws.Range("I" & rowNum).Interior.Color = RGB(255, 0, 0)
Exit Sub
End If
ws.Cells(rowNum, errorCol).ClearContents
End Sub
Sub ImportCSVAndTriggerChange(ws As Worksheet)
End Sub