add comment

This commit is contained in:
updsv7
2026-04-16 19:13:22 +09:00
parent db6a971473
commit 32420f8503
14 changed files with 200 additions and 33 deletions

View File

@@ -1,6 +1,13 @@
' ============================================================
' Generic Master Common Functions
' Module Name: Generic_Master_Common
' Module Desc: Generic Master Import/Export functions
' Module Methods:
' - Generic_Master_Import
' - Generic_Master_Export
' - Generic_ClearDataRows
' - GetCSVHeader
' ============================================================
Sub Generic_Master_Import(ByVal ws As Worksheet, ByVal expectedColumnCount As Long)
On Error GoTo ErrorHandler

View File

@@ -1,34 +1,38 @@
' ============================================================
' Modele Name: Global_Cache
' Modele Desc: Global Cache Module, Shared caches across all worksheets
' Module Name: Global_Cache
' Module Desc: Global Cache Module, Shared caches across all worksheets
' Module Methods:
' - RefreshM1Cache / ClearM1Cache
' - RefreshM1KukanDCache / ClearM1KukanDCache
' - RefreshM2Cache / ClearM2Cache
' - RefreshZ1Cache / ClearZ1Cache
' - RefreshZ2Cache / ClearZ2Cache
' - RefreshZ3Cache / ClearZ3Cache
' - RefreshO1Cache / ClearO1Cache
' - RefreshO2Cache / ClearO2Cache
' ============================================================
' M1 cache - used by M2_Kukan_detail, Tukin_C1
' Cache Variables
Public m1Cache As Object
' M1_KukanD cache - nested dict {D: {F: [G]}}
Public m1KukanDCache As Object
' Z1 cache - used by M1_Kukan
Public z1Cache As Object
' Z2 cache
Public z2Cache As Object
' Z3 cache
Public z3Cache As Object
' O1 cache - used by Tukin_C1
Public o1Cache As Object
' O2 cache
Public o2Cache As Object
' M2 cache - nested dictionary for Tukin_C1
Public m2Cache As Object
' m1Cache - used by M2_Kukan_detail, Tukin_C1
' m1KukanDCache - nested dict {D: {F: [G]}}
' z1Cache - used by M1_Kukan, Tukin_C1
' z2Cache
' z3Cache
' o1Cache - used by Tukin_C1
' o2Cache
' m2Cache - nested dictionary for Tukin_C1
' ============================================================
' M1 Cache
' M1 Cache - { 区間コード[C]: [value1-7] }
' ============================================================
Public Sub RefreshM1Cache()
Set m1Cache = Nothing
@@ -230,19 +234,51 @@ End Sub
' ============================================================
Public Sub RefreshO1Cache()
Set o1Cache = Nothing
Set o1Cache = CreateObject("Scripting.Dictionary")
On Error GoTo RefreshError
Set o1Cache = LoadLookup("O1", keyCol:=3, valueCols:=Array(5, 6), startRow:=7)
Dim wsO1 As Worksheet
On Error Resume Next
Set wsO1 = ThisWorkbook.Worksheets("O1")
If wsO1 Is Nothing Then Exit Sub
On Error GoTo 0
If o1Cache Is Nothing Or o1Cache.Count = 0 Then
Err.Raise 1001, "RefreshO1Cache", "O1 reference data is empty"
Dim lastRow As Long
lastRow = wsO1.Cells(wsO1.Rows.Count, 3).End(xlUp).Row
If lastRow < 7 Then Exit Sub
Dim r As Long
For r = 7 To lastRow
Dim cVal As String
cVal = Trim(wsO1.Cells(r, 3).Value) ' C column
Dim eVal As String
eVal = Trim(wsO1.Cells(r, 5).Value) ' E column
Dim fVal As String
fVal = Trim(wsO1.Cells(r, 6).Value) ' F column
If cVal = "" Or eVal = "" Then GoTo NextO1
' Outer: C column
If Not o1Cache.Exists(cVal) Then
Dim innerDict As Object
Set innerDict = CreateObject("Scripting.Dictionary")
o1Cache.Add cVal, innerDict
End If
Exit Sub
' Inner: E column -> array of F values
Set innerDict = o1Cache(cVal)
If Not innerDict.Exists(eVal) Then
Dim arr As Object
Set arr = CreateObject("Scripting.Dictionary")
innerDict.Add eVal, arr
End If
RefreshError:
Err.Raise 1002, "RefreshO1Cache", "Failed to load O1 lookup cache: " & Err.Description
Set arr = innerDict(eVal)
If fVal <> "" And Not arr.Exists(fVal) Then
arr.Add fVal, True
End If
NextO1:
Next r
End Sub
Public Sub ClearO1Cache()

View File

@@ -1,6 +1,17 @@
' ============================================================
' Module Name: Module_Common
' Module Desc: Common utility functions for all modules
' Module Methods:
' - GetLastDataRowInRange
' - ClearDataRows
' - ClearDataRow
' - SortDataRows
' - ToggleAutoFilter
' - AutoFitColumnWidth
' - GetSaveCSVPath
' ============================================================
' Common Functions
' ============================================================
' Get CSV header from specified row and columns
Function GetCSVHeader(ByVal ws As Worksheet, ByVal colLetters As Variant, ByVal headerRow As Long) As Variant

View File

@@ -1,3 +1,12 @@
' ============================================================
' Module Name: Read_Common
' Module Desc: CSV read functions
' Module Methods:
' - SelectCSVFile
' - ReadCSVAs2DArrayStrict
' - ParseCSVLines
' ============================================================
Function SelectCSVFile() As String
Dim fileDialog As FileDialog
Set fileDialog = Application.FileDialog(msoFileDialogFilePicker)

View File

@@ -1,7 +1,16 @@
' ============================================================
' Module Name: Test_Cache
' Module Desc: Debug module to print cache contents to Test_Cache sheet
' Module Methods:
' - Test_PrintAllCaches
' - PrintM1CacheToSheet
' - PrintM1KukanDCacheToSheet
' - PrintM2CacheToSheet
' - PrintZ1CacheToSheet
' - PrintO1CacheToSheet
' ============================================================
' Test Cache Module
' Debug: Print cache contents to Test_Cache sheet
' ============================================================
Sub Test_PrintAllCaches()
Call RefreshM1Cache

View File

@@ -1,3 +1,11 @@
' ============================================================
' Module Name: Write_Common
' Module Desc: CSV write functions
' Module Methods:
' - GetSaveCSVPath
' - WriteCSVFromArray
' ============================================================
Function GetSaveCSVPath(Optional ByVal defaultName As String = "") As String
Dim savePath As String
savePath = Application.GetSaveAsFilename( _

View File

@@ -1,3 +1,17 @@
' ============================================================
' Module Name: Master_M1_Kukan
' Module Desc: M1 Kukan master data management (import/export/validate)
' Module Methods:
' - M1_Import
' - M1_Export
' - M1_validateButton_Click
' - M1_SortDataRowsByC
' - M1_ToggleAutoFilter
' - M1_Worksheet_Change
' - M1_ValidateRow
' - M1_FillValidationDropdown
' - M1_ValidateAllRows
' ============================================================
' ====== Constants ======
Const START_COL As Long = 3 ' C column
Const END_COL As Long = 14 ' N column

View File

@@ -1,3 +1,17 @@
' ============================================================
' Module Name: Master_M2_Kukan_detail
' Module Desc: M2 Kukan detail master data management
' Module Methods:
' - M2_Import
' - M2_Export
' - M2_validateButton_Click
' - M2_SortDataRowsByC
' - M2_ToggleAutoFilter
' - M2_Worksheet_Change
' - M2_ValidateRow
' - M2_FillValidationDropdown
' - M2_ValidateAllRows
' ============================================================
' ====== Constants ======
Const START_COL As Long = 3 ' C column
Const END_COL As Long = 18 ' R column

View File

@@ -1,3 +1,12 @@
' ============================================================
' Module Name: Master_O1_address
' Module Desc: O1 address master data management
' Module Methods:
' - O1_Import
' - O1_Export
' - O1_SortDataRowsByC
' - O1_ToggleAutoFilter
' ============================================================
Sub O1_Import()
Dim filePath As String
Dim lines As Variant

View File

@@ -1,3 +1,12 @@
' ============================================================
' Module Name: Master_O2_507
' Module Desc: O2 master data management (507)
' Module Methods:
' - O2_Import
' - O2_Export
' - O2_SortDataRowsByC
' - O2_ToggleAutoFilter
' ============================================================
' ====== (507) =======
Sub O2_Import()
Call Generic_Master_Import(Me, 13)

View File

@@ -1,3 +1,12 @@
' ============================================================
' Module Name: Master_Z1_222
' Module Desc: Z1 master data management (222)
' Module Methods:
' - Z1_Import
' - Z1_Export
' - Z1_SortDataRowsByC
' - Z1_ToggleAutoFilter
' ============================================================
' ====== (222) =======
' ====== Constants ======

View File

@@ -1,3 +1,12 @@
' ============================================================
' Module Name: Master_Z2_223
' Module Desc: Z2 master data management (223)
' Module Methods:
' - Z2_Import
' - Z2_Export
' - Z2_SortDataRowsByC
' - Z2_ToggleAutoFilter
' ============================================================
' ====== (223) =======
' ====== Constants ======

View File

@@ -1,3 +1,12 @@
' ============================================================
' Module Name: Master_Z3_224
' Module Desc: Z3 master data management (224)
' Module Methods:
' - Z3_Import
' - Z3_Export
' - Z3_SortDataRowsByC
' - Z3_ToggleAutoFilter
' ============================================================
' ====== (224) =======
' ====== Constants ======

View File

@@ -1,3 +1,17 @@
' ============================================================
' Module Name: Tukin_C1
' Module Desc: Commuter allowance editing sheet (no CSV import)
' Module Methods:
' - Tukin_ValidateRow
' - FillTransportFromM1KukanD
' - FillDepartureFromM1KukanD
' - FillArrivalFromM1KukanD
' - FillKukanFromM1
' - FillKanshuFromM2
' - FillCodeFromM2
' - FillAddressFromO1
' - FillZ1Dropdown
' ============================================================
' ====== (Tukin_C1) =======
' Commuter allowance editing sheet
' No CSV import - direct editing only