通勤認定エクセルツール対応12 Z4マスタ追加

This commit is contained in:
guanxiangwei
2026-05-27 11:23:26 +09:00
parent ca2ae646fb
commit 1a0010b464
19 changed files with 163 additions and 343 deletions
+2 -2
View File
@@ -49,7 +49,7 @@ Sub RefreshCache_Button()
Dim activeSheetName As String: activeSheetName = ActiveSheet.CodeName
Debug.Print "1. Validate Z1~Z4, T1~T3, O1~O3 master data"
Dim cacheSheets As Variant: cacheSheets = Array("Z1", "Z2", "Z3", "T1", "T2", "T3", "O1", "O2", CACHE_O3)
Dim cacheSheets As Variant: cacheSheets = Array(CACHE_Z1, CACHE_Z2, CACHE_Z3, CACHE_Z4, CACHE_T1, CACHE_T2, CACHE_T3, CACHE_O1, CACHE_O2, CACHE_O3)
Dim sheetName As Variant
Dim ws As Worksheet
For Each sheetName In cacheSheets
@@ -325,7 +325,7 @@ Private Sub Do_Filter(ws As Excel.Worksheet)
Exit Sub
End If
Dim startCol As Long: startCol = ws.Range(sheetConf("StartCol") & "1").Column
Dim startCol As Long: startCol = ws.Range(sheetConf("ErrorCol") & "1").Column
Dim endCol As Long: endCol = ws.Range(sheetConf("EndCol") & "1").Column
Dim filterRow As Long: filterRow = sheetConf("FilterRow")
+51 -22
View File
@@ -8,7 +8,17 @@ Option Explicit
' - RefreshM2Cache
' - RefreshO1Cache
' ============================================================
Public Const CACHE_O3 As String = CACHE_O3
Public Const CACHE_Z1 As String = "Z1"
Public Const CACHE_Z2 As String = "Z2"
Public Const CACHE_Z3 As String = "Z3"
Public Const CACHE_Z4 As String = "Z4"
Public Const CACHE_T1 As String = "T1"
Public Const CACHE_T2 As String = "T2"
Public Const CACHE_T3 As String = "T3"
Public Const CACHE_O1 As String = "O1"
Public Const CACHE_O2 As String = "O2"
Public Const CACHE_O3 As String = "O3"
Private sheetConfDict As Object
@@ -53,7 +63,7 @@ Public Sub RefreshCache(ByVal cacheName As String)
Set loadedData = LookupM1KukanCache()
ElseIf cacheName = "M2" Then
Set loadedData = LookupM2Cache()
ElseIf cacheName = "O1" Then
ElseIf cacheName = CACHE_O1 Then
Set loadedData = LookupO1Cache()
ElseIf Contains(sheetConfDict("Enum"), cacheName) Then
Set loadedData = LoadLookup("Enum", cacheName)
@@ -217,11 +227,11 @@ Private Function LookupO1Cache() As Object
Dim ws As Worksheet
On Error Resume Next
Set ws = ThisWorkbook.Worksheets("O1")
Set ws = ThisWorkbook.Worksheets(CACHE_O1)
On Error GoTo ErrHandler
' ws exists, continue
Dim sheetConf As Object: Set sheetConf = sheetConfDict("O1")
Dim sheetConf As Object: Set sheetConf = sheetConfDict(CACHE_O1)
Dim startRow As Long: startRow = sheetConf("StartRow")
Dim lastRow As Long: lastRow = GetLastDataRowInRange(ws)
If lastRow < startRow Then
@@ -345,7 +355,7 @@ Private Sub RefreshSheetDict()
sheetConf("FilterRow") = 6
sheetConf("KeyCol") = 3
sheetConf("ValueCols") = Array(4)
Set sheetConfDict("Z1") = sheetConf
Set sheetConfDict(CACHE_Z1) = sheetConf
Debug.Print "RefreshSheetDict Z1 ok."
' Z2
@@ -363,7 +373,7 @@ Private Sub RefreshSheetDict()
sheetConf("FilterRow") = 6
sheetConf("KeyCol") = 3
sheetConf("ValueCols") = Array(4)
Set sheetConfDict("Z2") = sheetConf
Set sheetConfDict(CACHE_Z2) = sheetConf
Debug.Print "RefreshSheetDict Z2 ok."
' Z3
@@ -381,9 +391,27 @@ Private Sub RefreshSheetDict()
sheetConf("FilterRow") = 6
sheetConf("KeyCol") = 3
sheetConf("ValueCols") = Array(4)
Set sheetConfDict("Z3") = sheetConf
Set sheetConfDict(CACHE_Z3) = sheetConf
Debug.Print "RefreshSheetDict Z3 ok."
' Z4
Set sheetConf = CreateObject("Scripting.Dictionary")
sheetConf("StartCol") = "C"
sheetConf("EndCol") = "H"
sheetConf("ErrorCol") = "B"
sheetConf("StartRow") = 7
sheetConf("HeaderRow") = 5
sheetConf("CSV_Encoding") = "utf-8"
sheetConf("HasHeader") = False
sheetConf("ExpectedColumnCount") = 6
sheetConf("HeaderColumns") = Array("C", "D", "E", "F", "G", "H")
sheetConf("AlwaysQuote") = True
sheetConf("FilterRow") = 6
sheetConf("KeyCol") = 3
sheetConf("ValueCols") = Array(4)
Set sheetConfDict("Z4") = sheetConf
Debug.Print "RefreshSheetDict Z4 ok."
' T1
Set sheetConf = CreateObject("Scripting.Dictionary")
sheetConf("StartCol") = "C"
@@ -399,7 +427,7 @@ Private Sub RefreshSheetDict()
sheetConf("FilterRow") = 6
sheetConf("KeyCol") = 3
sheetConf("ValueCols") = Array(4)
Set sheetConfDict("T1") = sheetConf
Set sheetConfDict(CACHE_T1) = sheetConf
Debug.Print "RefreshSheetDict T1 ok."
' T2
@@ -417,7 +445,7 @@ Private Sub RefreshSheetDict()
sheetConf("FilterRow") = 6
sheetConf("KeyCol") = 3
sheetConf("ValueCols") = Array(4, 8, 9, 10, 11, 12, 13)
Set sheetConfDict("T2") = sheetConf
Set sheetConfDict(CACHE_T2) = sheetConf
Debug.Print "RefreshSheetDict T2 ok."
' T3
@@ -435,7 +463,7 @@ Private Sub RefreshSheetDict()
sheetConf("FilterRow") = 6
sheetConf("KeyCol") = 3
sheetConf("ValueCols") = Array(4, 8, 9)
Set sheetConfDict("T3") = sheetConf
Set sheetConfDict(CACHE_T3) = sheetConf
Debug.Print "RefreshSheetDict T3 ok."
' O1
@@ -451,7 +479,7 @@ Private Sub RefreshSheetDict()
sheetConf("HeaderColumns") = Array("C", "D", "E", "F")
sheetConf("AlwaysQuote") = True
sheetConf("FilterRow") = 5
Set sheetConfDict("O1") = sheetConf
Set sheetConfDict(CACHE_O1) = sheetConf
Debug.Print "RefreshSheetDict O1 ok."
' O2
@@ -469,7 +497,7 @@ Private Sub RefreshSheetDict()
sheetConf("FilterRow") = 5
sheetConf("KeyCol") = 3
sheetConf("ValueCols") = Array(4)
Set sheetConfDict("O2") = sheetConf
Set sheetConfDict(CACHE_O2) = sheetConf
Debug.Print "RefreshSheetDict O2 ok."
' O3
@@ -568,7 +596,7 @@ End Function
Public Sub RefreshMasterCache()
' Fixed cache names
Dim fixedCaches As Variant
fixedCaches = Array("Z1", "Z2", "Z3", "T1", "T2", "T3", "O1", "O2", CACHE_O3, _
fixedCaches = Array(CACHE_Z1, CACHE_Z2, CACHE_Z3, CACHE_T1, CACHE_T2, CACHE_T3, CACHE_O1, CACHE_O2, CACHE_O3, _
"tokubetuList", "kenshuList", "renrakuList", "oufukuList", "koutaiList", "higaitouList", "errorList")
' Refresh fixed caches
@@ -604,15 +632,16 @@ Public Sub WriteCachesSheet(ByVal cacheName As String)
' Map cacheName to column letter
Dim colLetter As String
Select Case cacheName
Case "Z1": colLetter = "A"
Case "Z2": colLetter = "B"
Case "Z3": colLetter = "C"
Case CACHE_O3: colLetter = "D"
Case "T1": colLetter = "E"
Case "T2": colLetter = "F"
Case "T3": colLetter = "G"
Case "O2": colLetter = "H"
Case "M1": colLetter = "I"
Case CACHE_Z1: colLetter = "A"
Case CACHE_Z2: colLetter = "B"
Case CACHE_Z3: colLetter = "C"
Case CACHE_Z4: colLetter = "D"
Case CACHE_T1: colLetter = "E"
Case CACHE_T2: colLetter = "F"
Case CACHE_T3: colLetter = "G"
Case CACHE_O2: colLetter = "H"
Case CACHE_O3: colLetter = "I"
Case "M1": colLetter = "M"
Case Else: Exit Sub
End Select
+3 -3
View File
@@ -19,7 +19,7 @@ Option Explicit
' ============================================================
' Create Transport (T) dropdown from Z1 cache
Public Function BuildTransportList()
Dim z1Cache As Object: Set z1Cache = GetCache("Z1")
Dim z1Cache As Object: Set z1Cache = GetCache(CACHE_Z1)
Dim dropdownList As String
Dim key As Variant
@@ -92,7 +92,7 @@ End Function
' Create Kettei (AU) dropdown
Public Function BuildKetteiList()
Dim z2Cache As Object: Set z2Cache = GetCache("Z2")
Dim z2Cache As Object: Set z2Cache = GetCache(CACHE_Z2)
Dim dropdownList As String
Dim key As Variant
@@ -128,7 +128,7 @@ End Function
' Create Kanshoku (BC) dropdown
Public Function BuildKanshokuList()
Dim o2Cache As Object: Set o2Cache = GetCache("O2")
Dim o2Cache As Object: Set o2Cache = GetCache(CACHE_O2)
Dim dropdownList As String
Dim key As Variant