This commit is contained in:
updsv7
2026-04-23 11:14:41 +09:00
parent 710845ff55
commit c6d53813e3
20 changed files with 292 additions and 217 deletions

View File

@@ -135,7 +135,9 @@ Private Sub Do_Validation(ws As Excel.Worksheet)
ElseIf errorCount > 0 Then
MsgBox "Validation complete. Errors: " & errorCount, vbInformation
Else
RefreshCache(ws.CodeName)
If ws.CodeName <> "C1" Then
RefreshCache(ws.CodeName)
End If
MsgBox "Validation complete. Errors: 0", vbInformation
End If

View File

@@ -18,6 +18,10 @@
' ============================================================
' Column arrays for 4 kukan sections
' ============================================================
Const CSHAINNO_COL As String = "C"
Const ADDRESS1_COL As String = "I"
Const ADDRESS2_COL As String = "J"
Private Function KUKAN_CODE_COLS() As Variant
KUKAN_CODE_COLS = Array(19, 26, 33, 40) ' S, Z, AG, AN
End Function
@@ -108,10 +112,11 @@ Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 3 Then
Dim cell As Range
For Each cell In Target
If Trim(cell.Value) = "" Then
Dim cshainno As String: cshainno = Trim(cell.Value)
If cshainno = "" Then
Call ClearRowData(cell.Row)
Else
Call CreateAddress1Dropdown(cell.Row)
Call CreateAddress1Dropdown(cell.Row, cshainno)
End If
Next
End If
@@ -136,7 +141,7 @@ Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 9 Then
Dim cellI As Range
For Each cellI In Target
Call CreateAddress2Dropdown(cellI.Row)
Call CreateAddress2Dropdown(cellI.Row)
Next
End If
@@ -312,18 +317,19 @@ Private Sub FillKukanFromM1(ByVal rowNum As Long, ByVal idx As Long)
End Sub
' triggered by c clomun cshainno input
Private Sub CreateAddress1Dropdown(ByVal rowNum As Long)
' when cshainno does not exist in o1, clear dropdownList and value
' when cshainno exist in o1, create dropdownList and value
Private Sub CreateAddress1Dropdown(ByVal rowNum As Long, ByVal cshainno As String)
Dim o1Cache As Object: Set o1Cache = GetCache("O1")
Dim empNo As String
empNo = Trim(Me.Cells(rowNum, 3).Value)
If empNo = "" Then Exit Sub
Me.Range("I" & rowNum).Validation.Delete
Me.Range("I" & rowNum).Value = ""
Me.Range("J" & rowNum).Validation.Delete
Me.Range("J" & rowNum).Value = ""
' Build dropdown list from O1 cache: get all E values for the C
Dim dropdownList As String
If o1Cache.Exists(empNo) Then
If o1Cache.Exists(cshainno) Then
Dim innerDict As Object
Set innerDict = o1Cache(empNo)
Set innerDict = o1Cache(cshainno)
Dim eKey As Variant
For Each eKey In innerDict.Keys
If dropdownList = "" Then
@@ -349,33 +355,26 @@ End Sub
' triggered by address1 select O1 cache
Private Sub CreateAddress2Dropdown(ByVal rowNum As Long)
' Clear address2 contents
Me.Range(ADDRESS2_COL & rowNum).Validation.Delete
Me.Range(ADDRESS2_COL & rowNum).Value = ""
' obtain cshainno, address1, o1Cache
Dim o1Cache As Object: Set o1Cache = GetCache("O1")
Dim empNo As String
empNo = Trim(Me.Cells(rowNum, 3).Value)
If empNo = "" Then
Me.Range("J" & rowNum).Validation.Delete
Me.Range("J" & rowNum).Value = ""
Exit Sub
End If
Dim addr1 As String
addr1 = Trim(Me.Cells(rowNum, 9).Value)
Me.Range("J" & rowNum).Value = ""
If addr1 = "" Then
Me.Range("J" & rowNum).Validation.Delete
Dim cshainno As String: cshainno = Trim(Me.Cells(rowNum, CSHAINNO_COL).Value)
Dim address1 As String: address1 = Trim(Me.Cells(rowNum, ADDRESS1_COL).Value)
If cshainno = "" OR address1 = "" Then
Exit Sub
End If
' Build dropdown list from O1 cache
Dim dropdownList As String
If o1Cache.Exists(empNo) Then
If o1Cache.Exists(cshainno) Then
Dim innerDict As Object
Set innerDict = o1Cache(empNo)
Set innerDict = o1Cache(cshainno)
If innerDict.Exists(addr1) Then
If innerDict.Exists(address1) Then
Dim addr2Dict As Object
Set addr2Dict = innerDict(addr1)
Set addr2Dict = innerDict(address1)
Dim addr2Key As Variant
For Each addr2Key In addr2Dict.Keys