diff --git a/README.md b/README.md new file mode 100644 index 0000000..e554229 --- /dev/null +++ b/README.md @@ -0,0 +1,54 @@ +# Commuter Allowance VBA Project + +Excel VBA commuter allowance calculation tool. + +## Structure + +``` +vba/ +├── 通勤手当テンプレート_案.xlsm # Main workbook +├── data/ # CSV data files +│ ├── 222交通機関名区分.csv # Transport type (222) +│ ├── 223通勤_決定事項区分.csv # Decision factors (223) +│ ├── 224通勤_手当月額の決定区分.csv # Monthly amount (224) +│ ├── 507発信者.csv # Sender (507) +│ ├── 区間.csv # Route (section) +│ └── 区間詳細.csv # Route details +└── src/ + ├── module/ # Common modules + │ ├── Common_Button.bas (306 lines) + │ ├── Common_File_Utils.bas (347 lines) + │ ├── Common_Functions.bas (478 lines) + │ ├── Common_Global_Cache.bas (817 lines) + │ └── Common_Selector.bas (161 lines) + ├── init_module/ # Init modules + │ ├── Import_modules.bas + │ └── Test_Cache.bas + └── sheet/ # Sheet classes + ├── C1.cls (842 lines) - Tukin_C1: Commuter allowance editing + ├── M1.cls (164 lines) - Master_Kukan: Route master (import/export/validate) + ├── M2.cls (386 lines) - Master_Kukan_detail: Route detail master + ├── O1.cls (5 lines) - Master_address: Address master + ├── O2.cls (6 lines) - Master_507: Sender master (507) + ├── T1.cls (57 lines) - Master_244: Route master (244) + ├── T2.cls (117 lines) - Master_245: Route master (245) + ├── T3.cls (77 lines) - Master_246 + ├── Z1.cls (67 lines) - Master_222: Transport type master + ├── Z2.cls (57 lines) - Master_223: Decision factors master + ├── Z3.cls (60 lines) - Master_224: Monthly amount master + └── Z4.cls (64 lines) - Master_225 +``` + +## Sheet Class Prefix + +| Prefix | Description | +|--------|-------------| +| C | Commuter allowance editing | +| M | Menu / Route master | +| O | Other masters | +| T | Route (通勤区間) | +| Z | Master data configuration | + +## License + +MIT \ No newline at end of file diff --git a/documents/Tukin_Cache_Mapping.md b/documents/Tukin_Cache_Mapping.md index 7bdd81d..9e1dc54 100644 --- a/documents/Tukin_Cache_Mapping.md +++ b/documents/Tukin_Cache_Mapping.md @@ -32,6 +32,8 @@ |--------|--------|--------| |ヘッダ|区分|手当月額の決定| +### t1Cache + ### o1Cache 住所情報 |列|C列|E列|F列| |--------|--------|--------|--------| diff --git a/src/module/Common_Button.bas b/src/module/Common_Button.bas index fb184e6..ad47c93 100644 --- a/src/module/Common_Button.bas +++ b/src/module/Common_Button.bas @@ -31,7 +31,25 @@ Sub Fit_Button() End Sub Sub RefreshCache_Button() - Dim result As Boolean: result = RefreshCache() + Dim cacheSheets As Variant: cacheSheets = Array("M1", "M2", "Z1", "Z2", "Z3", "Z4", "T1", "T2", "T3", "O1","O2") + + Dim sheetName As Variant + Dim ws As Worksheet + For Each sheetName In cacheSheets + If ProcedureExists(sheetName, "Validate") Then + Dim errorCount As Long + On Error Resume Next + Set ws = ThisWorkbook.Worksheets(CStr(sheetName)) + On Error GoTo 0 + Dim isValid As Boolean: isValid = RunValidationSilent(ws, errorCount) + If isValid = False Then + MsgBox "Can't refresh " & sheetName & " cache. Validation error occurs." + Exit Sub + End If + End If + Next sheetName + + Dim result As Boolean: result = RefreshAllCache() If result = True Then MsgBox "master data reload successfully." End If @@ -79,6 +97,11 @@ Private Sub DO_CSV_Import(ws As Excel.Worksheet) writeRow = writeRow + 1 Next i + ' === Step 5: Trigger sheet-specific import handler === + If ProcedureExists(ws.CodeName, "ImportCSVAndTriggerChange") Then + Call Application.Run(ws.CodeName & ".ImportCSVAndTriggerChange", ws, writeRow) + End If + MsgBox writeRow - cfg("StartRow") & " rows imported.", vbInformation GoTo FinallyExit @@ -94,13 +117,7 @@ End Sub Private Sub Do_Validation(ws As Excel.Worksheet) On Error GoTo ErrorHandler - Dim sheetConfDict As Object: Set sheetConfDict = GetSheetConfig() - Dim sheetConf As Object: Set sheetConf = sheetConfDict(ws.CodeName) - ' step1. confirm Validate Sub - Dim validate As String - validate = ws.CodeName & ".Validate" - If Not ProcedureExists(ws.CodeName, "Validate") Then MsgBox "worksheet """ & ws.name & """ unimplement methods", vbExclamation Exit Sub @@ -116,11 +133,7 @@ Private Sub Do_Validation(ws As Excel.Worksheet) ElseIf errorCount > 0 Then MsgBox "Validation complete. Errors: " & errorCount, vbInformation Else - 'There is no error - Dim cacheMethodName As String: cacheMethodName = Trim(sheetConf("RefreshCacheName")) - If cacheMethodName <> "" Then - Application.Run cacheMethodName - End If + RefreshCache(ws.CodeName) MsgBox "Validation complete. Errors: 0", vbInformation End If @@ -208,7 +221,30 @@ ExportError: End Sub Private Sub Do_Sort(ws As Excel.Worksheet) - ' + On Error GoTo ErrorHandler + + Dim sheetConfDict As Object: Set sheetConfDict = GetSheetConfig() + Dim sheetConf As Object: Set sheetConf = sheetConfDict(ws.CodeName) + + Dim startCol As String: startCol = sheetConf("StartCol") + Dim endCol As String: endCol = sheetConf("EndCol") + Dim startRow As Long: startRow = sheetConf("StartRow") + Dim lastDataRow As Long: lastDataRow = GetLastDataRowInRange(ws) + + If lastDataRow < startRow Then + MsgBox "No data to sort.", vbExclamation + Exit Sub + End If + + Dim sortRange As Range: Set sortRange = ws.Range(ws.Cells(startRow, ws.Range(startCol & "1").Column), ws.Cells(lastDataRow, ws.Range(endCol & "1").Column)) + sortRange.Select + + ' Show sort dialog + Application.Dialogs(xlDialogSort).Show + Exit Sub + +ErrorHandler: + MsgBox "Error: " & Err.Description, vbCritical End Sub Private Sub Do_Filter(ws As Excel.Worksheet) @@ -253,7 +289,7 @@ ErrorHandler: End Sub ' RunValidationSilent -private Function RunValidationSilent(ws As Worksheet, Optional ByRef errorCountOut As Long = 0) As Boolean +Public Function RunValidationSilent(ws As Worksheet, Optional ByRef errorCountOut As Long = 0) As Boolean On Error GoTo ErrorHandler Dim sheetConfDict As Object: Set sheetConfDict = GetSheetConfig() @@ -296,12 +332,18 @@ ErrorHandler: RunValidationSilent = False End Function -Private Function ProcedureExists(moduleName As String, procName As String) As Boolean +Public Function ProcedureExists(ByVal moduleName As String, ByVal procName As String) As Boolean Dim VBProj As Object, VBComp As Object, CodeMod As Object + + On Error Resume Next + Set VBProj = ThisWorkbook.VBProject Set VBComp = VBProj.VBComponents(moduleName) If Not VBComp Is Nothing Then Set CodeMod = VBComp.CodeModule ProcedureExists = (CodeMod.ProcStartLine(procName, 0) > 0) End If + + If Err.Number <> 0 Then ProcedureExists = False + On Error GoTo 0 End Function \ No newline at end of file diff --git a/src/module/Common_Functions.bas b/src/module/Common_Functions.bas index c9be4cd..da95ade 100644 --- a/src/module/Common_Functions.bas +++ b/src/module/Common_Functions.bas @@ -69,36 +69,61 @@ Function GetLastDataRow(ByVal ws As Worksheet, ByVal columnNum As Long) As Long GetLastDataRow = ws.Cells(ws.Rows.Count, columnNum).End(xlUp).Row End Function +Function Contains(ByVal arr As Variant, ByVal value As String) As Boolean + Dim i As Long + For i = 0 To UBound(arr) + If arr(i) = value Then + Contains = True + Exit Function + End If + Next i + + Contains = False +End Function + ' @return dict : key = keyCol,value = Array ' @param sheetName ' @param keyCol ' @param valueCols Array(4,5,6) ' @param startRow default is 7 -Function LoadLookup( _ - ByVal sheetName As String, _ - ByVal keyCol As Long, _ - ByVal valueCols As Variant, _ - Optional ByVal startRow As Long = 7 _ -) As Object - +Function LoadLookup(ByVal sheetName As String, ByVal cacheName As String) As Object + On Error GoTo ErrHandler + ' --- validate --- - If Trim(sheetName) = "" Then Exit Function - If Not IsArray(valueCols) Then - valueCols = Array(valueCols) + If Trim(sheetName) = "" Then Err.Raise 0001, "LoadLookup", "Sheet name cannot be empty." + + Dim sheetConfDict As Object: Set sheetConfDict = GetSheetConfig() + If Not sheetConfDict.Exists(sheetName) Then + Err.Raise 1004, "LoadLookup", "Sheet not configured: " & sheetName End If - Dim nValCols As Long: nValCols = UBound(valueCols) - LBound(valueCols) + 1 - If nValCols = 0 Then Exit Function ' --- obtain worksheet --- On Error Resume Next Dim ws As Worksheet: Set ws = ThisWorkbook.Worksheets(sheetName) - On Error GoTo 0 - If ws Is Nothing Then Exit Function - - ' --- obtain data(based on keyCol)--- - Dim lastRow As Long: lastRow = ws.Cells(ws.Rows.Count, keyCol).End(xlUp).Row - If lastRow < startRow Then Exit Function + If ws Is Nothing Then Err.Raise 0003, "LoadLookup", "Worksheet named '" & sheetName & "' not found." + On Error GoTo ErrHandler + + Dim sheetConf As Object: Set sheetConf = sheetConfDict(cacheName) + Dim startRow As Long: startRow = sheetConf("StartRow") + Dim keyCol As Long: keyCol = sheetConf("KeyCol") + Dim valueCols As Variant: valueCols = sheetConf("ValueCols") + + Dim lastRow As Long + If sheetName <> cacheName Then + lastRow = ws.Cells(ws.Rows.Count, keyCol).End(xlUp).Row + Else + lastRow = GetLastDataRowInRange(ws) + End If + Dim dict As Object: Set dict = CreateObject("Scripting.Dictionary") + If lastRow < startRow Then + Set LoadLookup = dict + Exit Function + End If + + Dim nValCols As Long: nValCols = UBound(valueCols) - LBound(valueCols) + 1 + If nValCols = 0 Then Err.Raise 0002, "LoadLookup", "Value columns parameter is invalid." + ' --- prepare col --- Dim minCol As Long: minCol = keyCol Dim maxCol As Long: maxCol = keyCol @@ -133,7 +158,6 @@ Function LoadLookup( _ Next i ' --- write into --- - Dim dict As Object: Set dict = CreateObject("Scripting.Dictionary") dict.CompareMode = vbTextCompare Dim r As Long @@ -150,6 +174,10 @@ Function LoadLookup( _ Next r Set LoadLookup = dict + Exit Function + +ErrHandler: + Err.Raise Err.Number, Err.Source, Err.Description End Function ' obtain @@ -205,7 +233,6 @@ Sub ClearDataRows(ByVal ws As Worksheet) Dim sheetConf As Object: Set sheetConf = sheetConfDict(ws.CodeName) - ' Dim startRow As Long: startRow = sheetConf("StartRow") Dim startCol As String: startCol = sheetConf("StartCol") Dim endCol As String: endCol = sheetConf("EndCol") @@ -320,8 +347,27 @@ Public Function FormatDateInput(ByVal inputStr As String) As String End If End Function +Function CheckHeaderEdit(ByVal ws As Worksheet, ByVal Target As Range) As Boolean + Dim sheetConfDict As Object: Set sheetConfDict = GetSheetConfig() + Dim sheetConf As Object: Set sheetConf = sheetConfDict(ws.CodeName) + Dim headerRow As Long: headerRow = sheetConf("HeaderRow") + + ' Check header row (headerRow) cannot be edited + If Target.Row = headerRow Then + Application.EnableEvents = False + MsgBox "Header row can not be edit", vbExclamation + Application.Undo + Application.EnableEvents = True + + CheckHeaderEdit = True + Exit Function + End If + + CheckHeaderEdit = False +End Function + Function GetErrorMsg(ByVal errorCode As String, Optional ByVal param0 As String = "", Optional ByVal param1 As String = "") As String - Dim errorList As Object: Set errorList = GetErrorList() + Dim errorList As Object: Set errorList = GetCache("errorList") Dim errorMessage As String If errorList.Exists(errorCode) Then errorMessage = Replace(errorList(errorCode)(0), "{0}", param0) diff --git a/src/module/Common_Global_Cache.bas b/src/module/Common_Global_Cache.bas index a6cd5ed..649409b 100644 --- a/src/module/Common_Global_Cache.bas +++ b/src/module/Common_Global_Cache.bas @@ -4,99 +4,146 @@ Option Explicit ' Module Name: Global_Cache ' Module Desc: Global Cache Module, Shared caches across all worksheets ' Module Methods: -' - RefreshM1Cache ' - RefreshM1KukanDCache ' - RefreshM2Cache -' - RefreshZ1Cache -' - RefreshZ2Cache -' - RefreshZ3Cache -' - RefreshZ4Cache ' - RefreshO1Cache -' - RefreshO2Cache ' ============================================================ - -' Cache Variables -Private m1Cache As Object -Private m1KukanDCache As Object -Private z1Cache As Object -Private z2Cache As Object -Private z3Cache As Object -Private z4Cache As Object -Private t1Cache As Object -Private t2Cache As Object -Private t3Cache As Object -Private o1Cache As Object -Private o2Cache As Object -Private m2Cache As Object -Private tokubetuList As Object -Private oufukuList As Object -Private koutaiList As Object -Private higaitouList As Object -Private kenshuList As Object -Private errorList As Object - Private sheetConfDict 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 +Public GlobalCache As Object -' ============================================================ -' M1 Cache - { 区間コード[C]: [value1-7] } -' ============================================================ -Private Sub RefreshM1Cache(Optional ByVal charset As String = "cp932") - Set m1Cache = Nothing - +Public Sub InitCacheManager() + If GlobalCache Is Nothing Then + Set GlobalCache = CreateObject("Scripting.Dictionary") + GlobalCache.CompareMode = vbTextCompare + End If +End Sub + +Public Function GetCache(ByVal cacheName As String) As Object + Dim cache As Object + Dim loadedData As Object + + ' On Error GoTo RefreshError - Set m1Cache = LoadLookup("M1", keyCol:=3, valueCols:=Array(3, 4, 5, 6, 7, 9, 12), startRow:=7) - On Error GoTo 0 - - If m1Cache Is Nothing Or m1Cache.Count = 0 Then - Err.Raise 1001, "RefreshM1Cache", "M1 reference data is empty" + + ' + If GlobalCache Is Nothing Then InitCacheManager + + ' + If Not GlobalCache.Exists(cacheName) Then + Set GlobalCache(cacheName) = CreateObject("Scripting.Dictionary") + GlobalCache(cacheName).CompareMode = vbTextCompare End If + Set cache = GlobalCache(cacheName) + Dim sheetConfDict As Object: Set sheetConfDict = GetSheetConfig() + If cache.Count = 0 Then + If cacheName = "M1KukanDCache" Then + Set loadedData = LookupM1KukanCache() + ElseIf cacheName = "M2" Then + Set loadedData = LookupM2Cache() + ElseIf cacheName = "O1" Then + Set loadedData = LookupO1Cache() + ElseIf Contains(sheetConfDict("Enum"), cacheName) Then + Set loadedData = LoadLookup("Enum", cacheName) + Else + Set loadedData = LoadLookup(cacheName, cacheName) + End If + + If Not loadedData Is Nothing Then + Set GlobalCache(cacheName) = loadedData + Set cache = loadedData + End If + End If + + Set GetCache = cache + Exit Function + +RefreshError: + Err.Raise 1001, "GetCache", "Failed to load " & cacheName & " lookup cache: " & Err.Description +End Function + +' before RefreshCache, should validate +Public Sub RefreshCache(ByVal cacheName As String) + Dim loadedData As Object + + ' + On Error GoTo RefreshError + + ' + If GlobalCache Is Nothing Then InitCacheManager + + ' + If Not GlobalCache.Exists(cacheName) Then + Set GlobalCache(cacheName) = CreateObject("Scripting.Dictionary") + GlobalCache(cacheName).CompareMode = vbTextCompare + End If + + Dim sheetConfDict As Object: Set sheetConfDict = GetSheetConfig() + If cacheName = "M1KukanDCache" Then + Set loadedData = LookupM1KukanCache() + ElseIf cacheName = "M2" Then + Set loadedData = LookupM2Cache() + ElseIf cacheName = "O1" Then + Set loadedData = LookupO1Cache() + ElseIf Contains(sheetConfDict("Enum"), cacheName) Then + Set loadedData = LoadLookup("Enum", cacheName) + Else + Set loadedData = LoadLookup(cacheName, cacheName) + End If + + If Not loadedData Is Nothing Then + Set GlobalCache(cacheName) = loadedData + End If + Exit Sub RefreshError: - Err.Raise 1002, "RefreshM1Cache", "Failed to load M1 lookup cache: " & Err.Description + Err.Raise 1001, "RefreshCache", "Failed to load " & cacheName & " lookup cache: " & Err.Description End Sub ' Refresh M1_KukanD cache - nested dict {D: {F: [G]}} ' Structure: { 交通機関区分[D]: { 利用区間発名[F]: [利用区間着名G] } } -Private Sub RefreshM1KukanDCache() - Set m1KukanDCache = Nothing - Set m1KukanDCache = CreateObject("Scripting.Dictionary") +Private Function LookupM1KukanCache() + Dim resultCache As Object + Set resultCache = CreateObject("Scripting.Dictionary") - Dim wsM1 As Worksheet + On Error GoTo ErrHandler + + Dim ws As Worksheet On Error Resume Next - Set wsM1 = ThisWorkbook.Worksheets("M1") - If wsM1 Is Nothing Then Exit Sub - On Error GoTo 0 + Set ws = ThisWorkbook.Worksheets("M1") + On Error GoTo ErrHandler + + If ws Is Nothing Then + Set LookupM1KukanCache = resultCache + Exit Function + End If - Dim lastRow As Long: lastRow = wsM1.Cells(wsM1.Rows.Count, 3).End(xlUp).Row - If lastRow < 7 Then Exit Sub + Dim sheetConf As Object: Set sheetConf = sheetConfDict("M1") + Dim startRow As Long: startRow = sheetConf("StartRow") + Dim lastRow As Long: lastRow = GetLastDataRowInRange(ws) + If lastRow < startRow Then + Set LookupM2Cache = resultCache + Exit Function + End If Dim r As Long - For r = 7 To lastRow - Dim dValue As String: dValue = Trim(wsM1.Cells(r, 4).Value) ' D column - Dim fValue As String: fValue = Trim(wsM1.Cells(r, 6).Value) ' F column - Dim gValue As String: gValue = Trim(wsM1.Cells(r, 7).Value) ' G column + For r = startRow To lastRow + Dim dValue As String: dValue = Trim(ws.Cells(r, 4).Value) ' D column + Dim fValue As String: fValue = Trim(ws.Cells(r, 6).Value) ' F column + Dim gValue As String: gValue = Trim(ws.Cells(r, 7).Value) ' G column If dValue = "" Or fValue = "" Then GoTo NextRow2 ' Outer level: D column (交通機関区分) - If Not m1KukanDCache.Exists(dValue) Then + If Not resultCache.Exists(dValue) Then Dim innerDict As Object: Set innerDict = CreateObject("Scripting.Dictionary") - m1KukanDCache.Add dValue, innerDict + resultCache.Add dValue, innerDict End If ' Inner level: F column (利用区間発名) -> array of G values - Set innerDict = m1KukanDCache(dValue) + Set innerDict = resultCache(dValue) If Not innerDict.Exists(fValue) Then Dim arr As Object: Set arr = CreateObject("Scripting.Dictionary") innerDict.Add fValue, arr @@ -109,42 +156,59 @@ Private Sub RefreshM1KukanDCache() NextRow2: Next r -End Sub + + Set LookupM1KukanCache = resultCache + Exit Function + +ErrHandler: + Err.Raise Err.Number, Err.Source, Err.Description +End Function ' ============================================================ ' M2 Cache - Nested Dictionary ' Structure: { 区間コード[C]: { 券種[I]: { コード[J]: K } } } ' ============================================================ -Private Sub RefreshM2Cache() - Set m2Cache = Nothing - Set m2Cache = CreateObject("Scripting.Dictionary") +Private Function LookupM2Cache() As Object + Dim resultCache As Object + Set resultCache = CreateObject("Scripting.Dictionary") - Dim wsM2 As Worksheet + On Error GoTo ErrHandler + + Dim ws As Worksheet On Error Resume Next - Set wsM2 = ThisWorkbook.Worksheets("M2") - If wsM2 Is Nothing Then Exit Sub - On Error GoTo 0 + Set ws = ThisWorkbook.Worksheets("M2") + On Error GoTo ErrHandler + + If ws Is Nothing Then + Set LookupM2Cache = resultCache + Exit Function + End If - Dim lastRow As Long: lastRow = wsM2.Cells(wsM2.Rows.Count, 3).End(xlUp).Row - If lastRow < 7 Then Exit Sub + Dim sheetConf As Object: Set sheetConf = sheetConfDict("M2") + Dim startRow As Long: startRow = sheetConf("StartRow") + Dim lastRow As Long: lastRow = GetLastDataRowInRange(ws) + If lastRow < startRow Then + Set LookupM2Cache = resultCache + Exit Function + End If Dim r As Long - For r = 7 To lastRow - Dim kukanCode As String: kukanCode = Trim(wsM2.Cells(r, 3).Value) ' C column - Dim kanshu As String: kanshu = Trim(wsM2.Cells(r, 9).Value) ' I column - Dim code As String: code = Trim(wsM2.Cells(r, 10).Value) ' J column - Dim name As String: name = Trim(wsM2.Cells(r, 11).Value) ' K column + For r = startRow To lastRow + Dim kukanCode As String: kukanCode = Trim(ws.Cells(r, 3).Value) ' C column + Dim kanshu As String: kanshu = Trim(ws.Cells(r, 9).Value) ' I column + Dim code As String: code = Trim(ws.Cells(r, 10).Value) ' J column + Dim name As String: name = Trim(ws.Cells(r, 11).Value) ' K column If kukanCode = "" Or kanshu = "" Or code = "" Then GoTo NextRow ' Outer level: kukanCode - If Not m2Cache.Exists(kukanCode) Then + If Not resultCache.Exists(kukanCode) Then Dim innerDict As Object: Set innerDict = CreateObject("Scripting.Dictionary") - m2Cache.Add kukanCode, innerDict + resultCache.Add kukanCode, innerDict End If ' Middle level: kanshu - Set innerDict = m2Cache(kukanCode) + Set innerDict = resultCache(kukanCode) If Not innerDict.Exists(kanshu) Then Dim innermostDict As Object: Set innermostDict = CreateObject("Scripting.Dictionary") innerDict.Add kanshu, innermostDict @@ -158,183 +222,59 @@ Private Sub RefreshM2Cache() NextRow: Next r -End Sub -' ============================================================ -' Z1 Cache -' ============================================================ -Private Sub RefreshZ1Cache() - Set z1Cache = Nothing - - On Error GoTo RefreshError - Set z1Cache = LoadLookup("Z1", keyCol:=3, valueCols:=Array(4), startRow:=7) - On Error GoTo 0 + Set LookupM2Cache = resultCache + Exit Function - 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 - -' ============================================================ -' Z2 Cache -' ============================================================ -Private Sub RefreshZ2Cache() - Set z2Cache = Nothing - - On Error GoTo RefreshError - Set z2Cache = LoadLookup("Z2", keyCol:=3, valueCols:=Array(4), startRow:=7) - On Error GoTo 0 - - If z2Cache Is Nothing Or z2Cache.Count = 0 Then - Err.Raise 1001, "RefreshZ2Cache", "Z2 reference data is empty" - End If - - Exit Sub - -RefreshError: - Err.Raise 1002, "RefreshZ2Cache", "Failed to load Z2 lookup cache: " & Err.Description -End Sub - -' ============================================================ -' Z3 Cache -' ============================================================ -Private Sub RefreshZ3Cache() - Set z3Cache = Nothing - - On Error GoTo RefreshError - Set z3Cache = LoadLookup("Z3", keyCol:=3, valueCols:=Array(4), startRow:=7) - On Error GoTo 0 - - If z3Cache Is Nothing Or z3Cache.Count = 0 Then - Err.Raise 1001, "RefreshZ3Cache", "Z3 reference data is empty" - End If - - Exit Sub - -RefreshError: - Err.Raise 1002, "RefreshZ3Cache", "Failed to load Z3 lookup cache: " & Err.Description -End Sub - -' ============================================================ -' z4Cache -' ============================================================ -Private Sub RefreshZ4Cache() - On Error GoTo RefreshError - Set z4Cache = LoadLookup("Z4", keyCol:=3, valueCols:=Array(4), startRow:=7) - On Error GoTo 0 - - If z4Cache Is Nothing Or z4Cache.Count = 0 Then - Err.Raise 1003, "RefreshZ4Cache", "Enum reference data is empty" - End If - - Exit Sub - -RefreshError: - Err.Raise 1001, "RefreshZ4Cache", "Failed to load Enum lookup cache: " & Err.Description -End Sub - -' ============================================================ -' T1 Cache -' ============================================================ -Private Sub RefreshT1Cache() - Set t1Cache = Nothing - - On Error GoTo RefreshError - Set t1Cache = LoadLookup("T1", keyCol:=3, valueCols:=Array(4), startRow:=7) - On Error GoTo 0 - - If t1Cache Is Nothing Or t1Cache.Count = 0 Then - Err.Raise 1001, "RefreshT1Cache", "T1 reference data is empty" - End If - - Exit Sub - -RefreshError: - Err.Raise 1002, "RefreshT1Cache", "Failed to load T1 lookup cache: " & Err.Description -End Sub - -' ============================================================ -' T2 Cache -' ============================================================ -Private Sub RefreshT2Cache() - Set t2Cache = Nothing - - On Error GoTo RefreshError - Set t2Cache = LoadLookup("T2", keyCol:=3, valueCols:=Array(4, 6, 8, 9, 10, 11, 12, 13), startRow:=7) - On Error GoTo 0 - - If t2Cache Is Nothing Or t2Cache.Count = 0 Then - Err.Raise 1001, "RefreshT2Cache", "T2 reference data is empty" - End If - - Exit Sub - -RefreshError: - Err.Raise 1002, "RefreshT2Cache", "Failed to load T2 lookup cache: " & Err.Description -End Sub - -' ============================================================ -' T3 Cache -' ============================================================ -Private Sub RefreshT3Cache() - Set t3Cache = Nothing - - On Error GoTo RefreshError - Set t3Cache = LoadLookup("T3", keyCol:=3, valueCols:=Array(4, 8, 9), startRow:=7) - On Error GoTo 0 - - If t3Cache Is Nothing Or t3Cache.Count = 0 Then - Err.Raise 1001, "RefreshT3Cache", "T3 reference data is empty" - End If - - Exit Sub - -RefreshError: - Err.Raise 1002, "RefreshT3Cache", "Failed to load T3 lookup cache: " & Err.Description -End Sub +ErrHandler: + Err.Raise Err.Number, Err.Source, Err.Description +End Function ' ============================================================ ' O1 Cache ' ============================================================ -Private Sub RefreshO1Cache() - Set o1Cache = Nothing - Set o1Cache = CreateObject("Scripting.Dictionary") +Private Function LookupO1Cache() As Object + Dim resultCache As Object + Set resultCache = CreateObject("Scripting.Dictionary") - Dim wsO1 As Worksheet + Dim ws As Worksheet On Error Resume Next - Set wsO1 = ThisWorkbook.Worksheets("O1") - If wsO1 Is Nothing Then Exit Sub - On Error GoTo 0 + Set ws = ThisWorkbook.Worksheets("O1") + On Error GoTo ErrHandler + + If ws Is Nothing Then + Set LookupO1Cache = resultCache + Exit Function + End If - Dim lastRow As Long - lastRow = wsO1.Cells(wsO1.Rows.Count, 3).End(xlUp).Row - If lastRow < 6 Then Exit Sub + Dim sheetConf As Object: Set sheetConf = sheetConfDict("O1") + Dim startRow As Long: startRow = sheetConf("StartRow") + Dim lastRow As Long: lastRow = GetLastDataRowInRange(ws) + If lastRow < startRow Then + Set LookupO1Cache = resultCache + Exit Function + End If Dim r As Long - For r = 6 To lastRow + For r = startRow To lastRow Dim cVal As String - cVal = Trim(wsO1.Cells(r, 3).Value) ' C column + cVal = Trim(ws.Cells(r, 3).Value) ' C column Dim eVal As String - eVal = Trim(wsO1.Cells(r, 5).Value) ' E column + eVal = Trim(ws.Cells(r, 5).Value) ' E column Dim fVal As String - fVal = Trim(wsO1.Cells(r, 6).Value) ' F column + fVal = Trim(ws.Cells(r, 6).Value) ' F column If cVal = "" Or eVal = "" Then GoTo NextO1 ' Outer: C column - If Not o1Cache.Exists(cVal) Then + If Not resultCache.Exists(cVal) Then Dim innerDict As Object Set innerDict = CreateObject("Scripting.Dictionary") - o1Cache.Add cVal, innerDict + resultCache.Add cVal, innerDict End If ' Inner: E column -> array of F values - Set innerDict = o1Cache(cVal) + Set innerDict = resultCache(cVal) If Not innerDict.Exists(eVal) Then Dim arr As Object Set arr = CreateObject("Scripting.Dictionary") @@ -348,356 +288,284 @@ Private Sub RefreshO1Cache() NextO1: Next r -End Sub -' ============================================================ -' O2 Cache -' ============================================================ -Private Sub RefreshO2Cache() - Set o2Cache = Nothing - - On Error GoTo RefreshError - Set o2Cache = LoadLookup("O2", keyCol:=3, valueCols:=Array(4), startRow:=6) - On Error GoTo 0 + Set LookupO1Cache = resultCache + Exit Function - If o2Cache Is Nothing Or o2Cache.Count = 0 Then - Err.Raise 1001, "RefreshO2Cache", "O2 reference data is empty" - End If - - Exit Sub - -RefreshError: - Err.Raise 1002, "RefreshO2Cache", "Failed to load O2 lookup cache: " & Err.Description -End Sub - -' ============================================================ -' tokubetuList -' ============================================================ -Private Sub RefreshTokubetu() - On Error GoTo RefreshError - Set tokubetuList = LoadLookup("Enum", keyCol:=1, valueCols:=Array(1), startRow:=3) - On Error GoTo 0 - - If tokubetuList Is Nothing Or tokubetuList.Count = 0 Then - Err.Raise 1003, "GetTokubetu", "Enum reference data is empty" - End If - - Exit Sub - -RefreshError: - Err.Raise 1001, "GetTokubetu", "Failed to load Enum lookup cache: " & Err.Description -End Sub - -' ============================================================ -' oufukuList -' ============================================================ -Private Sub RefreshOufukuList() - On Error GoTo RefreshError - Set oufukuList = LoadLookup("Enum", keyCol:=6, valueCols:=Array(7), startRow:=3) - On Error GoTo 0 - - If oufukuList Is Nothing Or oufukuList.Count = 0 Then - Err.Raise 1003, "GetOufukuList", "Enum reference data is empty" - End If - - Exit Sub - -RefreshError: - Err.Raise 1001, "GetOufukuList", "Failed to load Enum lookup cache: " & Err.Description -End Sub - -' ============================================================ -' koutaiList -' ============================================================ -Private Sub RefreshKoutaiList() - On Error GoTo RefreshError - Set koutaiList = LoadLookup("Enum", keyCol:=9, valueCols:=Array(10), startRow:=3) - On Error GoTo 0 - - If koutaiList Is Nothing Or koutaiList.Count = 0 Then - Err.Raise 1003, "GetKoutaiList", "Enum reference data is empty" - End If - - Exit Sub - -RefreshError: - Err.Raise 1001, "GetKoutaiList", "Failed to load Enum lookup cache: " & Err.Description -End Sub - -' ============================================================ -' higaitouList -' ============================================================ -Private Sub RefreshHigaitouList() - On Error GoTo RefreshError - Set higaitouList = LoadLookup("Enum", keyCol:=12, valueCols:=Array(13), startRow:=3) - On Error GoTo 0 - - If higaitouList Is Nothing Or higaitouList.Count = 0 Then - Err.Raise 1003, "GetHigaitouList", "Enum reference data is empty" - End If - - Exit Sub - -RefreshError: - Err.Raise 1001, "GetHigaitouList", "Failed to load Enum lookup cache: " & Err.Description -End Sub - -' ============================================================ -' higaitouList -' ============================================================ -Private Sub RefreshKenshuList() - On Error GoTo RefreshError - Set kenshuList = LoadLookup("Enum", keyCol:=3, valueCols:=Array(4), startRow:=3) - On Error GoTo 0 - - If kenshuList Is Nothing Or kenshuList.Count = 0 Then - Err.Raise 1003, "RefreshKenshuList", "Enum reference data is empty" - End If - - Exit Sub - -RefreshError: - Err.Raise 1001, "RefreshKenshuList", "Failed to load Enum lookup cache: " & Err.Description -End Sub - -' ============================================================ -' higaitouList -' ============================================================ -Private Sub RefreshErrorList() - Set errorList = Nothing - On Error GoTo RefreshError - Set errorList = LoadLookup("Enum", keyCol:=18, valueCols:=Array(19), startRow:=3) - On Error GoTo 0 - - If errorList Is Nothing Or errorList.Count = 0 Then - Err.Raise 1003, "RefreshErrorList", "Enum reference data is empty" - End If - - Exit Sub - -RefreshError: - Err.Raise 1001, "RefreshErrorList", "Failed to load Enum lookup cache: " & Err.Description -End Sub +ErrHandler: + Err.Raise Err.Number, Err.Source, Err.Description +End Function Private Sub RefreshSheetDict() + Debug.Print "RefreshSheetDict begin." Set sheetConfDict = CreateObject("Scripting.Dictionary") Dim sheetConf As Object ' C1 Set sheetConf = CreateObject("Scripting.Dictionary") - sheetConf("StartCol") = "C" sheetConf("EndCol") = "BC" sheetConf("ErrorCol") = "BD" sheetConf("StartRow") = 8 sheetConf("HeaderRow") = 6 - sheetConf("RefreshCacheName") = "" sheetConf("CSV_Encoding") = "shift_jis" sheetConf("HasHeader") = True sheetConf("ExpectedColumnCount") = 41 sheetConf("HeaderColumns") = Array("C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "W", "X", "Y", "Z", "AD", "AE", "AF", "AG", "AK", "AL", "AM", "AN", "AR", "AS", "AT", "AU", "AV", "AW", "AX", "AY", "AZ", "BA", "BB", "BC") sheetConf("AlwaysQuote") = False sheetConf("FilterRow") = 7 - Set sheetConfDict("C1") = sheetConf + Debug.Print "RefreshSheetDict C1 ok." ' M1 Set sheetConf = CreateObject("Scripting.Dictionary") - sheetConf("StartCol") = "C" sheetConf("EndCol") = "N" sheetConf("ErrorCol") = "O" sheetConf("StartRow") = 7 sheetConf("HeaderRow") = 5 - sheetConf("RefreshCacheName") = "RefreshM1Cache" + sheetConf("CacheName") = "m1Cache" sheetConf("CSV_Encoding") = "shift_jis" sheetConf("HasHeader") = True sheetConf("ExpectedColumnCount") = 12 sheetConf("HeaderColumns") = Array("C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N") sheetConf("AlwaysQuote") = False sheetConf("FilterRow") = 6 - + sheetConf("KeyCol") = 3 + sheetConf("ValueCols") = Array(3, 4, 5, 6, 7, 9, 12) Set sheetConfDict("M1") = sheetConf + Debug.Print "RefreshSheetDict M1 ok." ' M2 Set sheetConf = CreateObject("Scripting.Dictionary") - sheetConf("StartCol") = "C" sheetConf("EndCol") = "R" sheetConf("ErrorCol") = "S" sheetConf("StartRow") = 7 - sheetConf("HeaderRow") = 5 - sheetConf("RefreshCacheName") = "RefreshM2Cache" + sheetConf("HeaderRow") = 6 sheetConf("CSV_Encoding") = "shift_jis" sheetConf("HasHeader") = True sheetConf("ExpectedColumnCount") = 11 sheetConf("HeaderColumns") = Array("C", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R") sheetConf("AlwaysQuote") = False sheetConf("FilterRow") = 6 - Set sheetConfDict("M2") = sheetConf + Debug.Print "RefreshSheetDict M2 ok." ' Z1 Set sheetConf = CreateObject("Scripting.Dictionary") - sheetConf("StartCol") = "C" sheetConf("EndCol") = "I" sheetConf("ErrorCol") = "B" sheetConf("StartRow") = 7 sheetConf("HeaderRow") = 5 - sheetConf("RefreshCacheName") = "RefreshZ1Cache" sheetConf("CSV_Encoding") = "utf-8" sheetConf("HasHeader") = False sheetConf("ExpectedColumnCount") = 7 sheetConf("HeaderColumns") = Array("C", "D", "E", "F", "G", "H", "I") sheetConf("AlwaysQuote") = True sheetConf("FilterRow") = 6 - + sheetConf("KeyCol") = 3 + sheetConf("ValueCols") = Array(4) Set sheetConfDict("Z1") = sheetConf + Debug.Print "RefreshSheetDict Z1 ok." ' Z2 Set sheetConf = CreateObject("Scripting.Dictionary") - sheetConf("StartCol") = "C" sheetConf("EndCol") = "G" sheetConf("ErrorCol") = "B" sheetConf("StartRow") = 7 sheetConf("HeaderRow") = 5 - sheetConf("RefreshCacheName") = "RefreshZ2Cache" sheetConf("CSV_Encoding") = "utf-8" sheetConf("HasHeader") = False sheetConf("ExpectedColumnCount") = 5 sheetConf("HeaderColumns") = Array("C", "D", "E", "F", "G") sheetConf("AlwaysQuote") = True sheetConf("FilterRow") = 6 - + sheetConf("KeyCol") = 3 + sheetConf("ValueCols") = Array(4) Set sheetConfDict("Z2") = sheetConf + Debug.Print "RefreshSheetDict Z2 ok." ' Z3 Set sheetConf = CreateObject("Scripting.Dictionary") - sheetConf("StartCol") = "C" sheetConf("EndCol") = "H" sheetConf("ErrorCol") = "B" sheetConf("StartRow") = 7 sheetConf("HeaderRow") = 5 - sheetConf("RefreshCacheName") = "RefreshZ3Cache" 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("Z3") = sheetConf + Debug.Print "RefreshSheetDict Z3 ok." ' Z4 Set sheetConf = CreateObject("Scripting.Dictionary") - sheetConf("StartCol") = "C" sheetConf("EndCol") = "I" sheetConf("ErrorCol") = "B" sheetConf("StartRow") = 7 sheetConf("HeaderRow") = 5 - sheetConf("RefreshCacheName") = "RefreshZ4Cache" sheetConf("CSV_Encoding") = "utf-8" sheetConf("HasHeader") = False sheetConf("ExpectedColumnCount") = 7 sheetConf("HeaderColumns") = Array("C", "D", "E", "F", "G", "H", "I") 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" sheetConf("EndCol") = "G" sheetConf("ErrorCol") = "B" sheetConf("StartRow") = 7 sheetConf("HeaderRow") = 5 - sheetConf("RefreshCacheName") = "RefreshT1Cache" sheetConf("CSV_Encoding") = "utf-8" sheetConf("HasHeader") = False sheetConf("ExpectedColumnCount") = 5 sheetConf("HeaderColumns") = Array("C", "D", "E", "F", "G") sheetConf("AlwaysQuote") = True sheetConf("FilterRow") = 6 - + sheetConf("KeyCol") = 3 + sheetConf("ValueCols") = Array(4) Set sheetConfDict("T1") = sheetConf + Debug.Print "RefreshSheetDict T1 ok." ' T2 Set sheetConf = CreateObject("Scripting.Dictionary") - sheetConf("StartCol") = "C" sheetConf("EndCol") = "M" sheetConf("ErrorCol") = "B" sheetConf("StartRow") = 7 sheetConf("HeaderRow") = 5 - sheetConf("RefreshCacheName") = "RefreshT2Cache" sheetConf("CSV_Encoding") = "utf-8" sheetConf("HasHeader") = False sheetConf("ExpectedColumnCount") = 11 sheetConf("HeaderColumns") = Array("C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M") sheetConf("AlwaysQuote") = True sheetConf("FilterRow") = 6 - + sheetConf("KeyCol") = 3 + sheetConf("ValueCols") = Array(4, 6, 8, 9, 10, 11, 12, 13) Set sheetConfDict("T2") = sheetConf + Debug.Print "RefreshSheetDict T2 ok." ' T3 Set sheetConf = CreateObject("Scripting.Dictionary") - sheetConf("StartCol") = "C" sheetConf("EndCol") = "I" sheetConf("ErrorCol") = "B" sheetConf("StartRow") = 7 sheetConf("HeaderRow") = 5 - sheetConf("RefreshCacheName") = "RefreshT3Cache" sheetConf("CSV_Encoding") = "utf-8" sheetConf("HasHeader") = False sheetConf("ExpectedColumnCount") = 7 sheetConf("HeaderColumns") = Array("C", "D", "E", "F", "G", "H", "I") sheetConf("AlwaysQuote") = True sheetConf("FilterRow") = 6 - + sheetConf("KeyCol") = 3 + sheetConf("ValueCols") = Array(4, 8, 9) Set sheetConfDict("T3") = sheetConf + Debug.Print "RefreshSheetDict T3 ok." ' O1 Set sheetConf = CreateObject("Scripting.Dictionary") - sheetConf("StartCol") = "C" sheetConf("EndCol") = "F" sheetConf("ErrorCol") = "" sheetConf("StartRow") = 6 sheetConf("HeaderRow") = "" - sheetConf("RefreshCacheName") = "RefreshO1Cache" sheetConf("CSV_Encoding") = "utf-8" sheetConf("HasHeader") = False sheetConf("ExpectedColumnCount") = 4 sheetConf("HeaderColumns") = Array() sheetConf("AlwaysQuote") = True sheetConf("FilterRow") = 5 - Set sheetConfDict("O1") = sheetConf + Debug.Print "RefreshSheetDict O1 ok." ' O2 Set sheetConf = CreateObject("Scripting.Dictionary") - sheetConf("StartCol") = "C" sheetConf("EndCol") = "O" sheetConf("ErrorCol") = "" sheetConf("StartRow") = 6 sheetConf("HeaderRow") = "" - sheetConf("RefreshCacheName") = "RefreshO2Cache" sheetConf("CSV_Encoding") = "utf-8" sheetConf("HasHeader") = False sheetConf("ExpectedColumnCount") = 13 sheetConf("HeaderColumns") = Array() sheetConf("AlwaysQuote") = True sheetConf("FilterRow") = 5 - + sheetConf("KeyCol") = 3 + sheetConf("ValueCols") = Array(4) Set sheetConfDict("O2") = sheetConf + Debug.Print "RefreshSheetDict O2 ok." + + ' Enum + Set sheetConf = Nothing + sheetConfDict("Enum") = Array("tokubetuList", "kenshuList", "oufukuList", "koutaiList", "higaitouList", "errorList") + Debug.Print "RefreshSheetDict Enum ok." + + ' tokubetuList + Set sheetConf = CreateObject("Scripting.Dictionary") + sheetConf("StartRow") = 3 + sheetConf("KeyCol") = 1 + sheetConf("ValueCols") = Array(1) + Set sheetConfDict("tokubetuList") = sheetConf + Debug.Print "RefreshSheetDict tokubetuList ok." + + ' kenshuList + Set sheetConf = CreateObject("Scripting.Dictionary") + sheetConf("StartRow") = 3 + sheetConf("KeyCol") = 3 + sheetConf("ValueCols") = Array(4) + Set sheetConfDict("kenshuList") = sheetConf + Debug.Print "RefreshSheetDict kenshuList ok." + + ' oufukuList + Set sheetConf = CreateObject("Scripting.Dictionary") + sheetConf("StartRow") = 3 + sheetConf("KeyCol") = 6 + sheetConf("ValueCols") = Array(6) + Set sheetConfDict("oufukuList") = sheetConf + Debug.Print "RefreshSheetDict oufukuList ok." + + ' koutaiList + Set sheetConf = CreateObject("Scripting.Dictionary") + sheetConf("StartRow") = 3 + sheetConf("KeyCol") = 9 + sheetConf("ValueCols") = Array(10) + Set sheetConfDict("koutaiList") = sheetConf + Debug.Print "RefreshSheetDict koutaiList ok." + + ' higaitouList + Set sheetConf = CreateObject("Scripting.Dictionary") + sheetConf("StartRow") = 3 + sheetConf("KeyCol") = 12 + sheetConf("ValueCols") = Array(13) + Set sheetConfDict("higaitouList") = sheetConf + Debug.Print "RefreshSheetDict higaitouList ok." + + ' errorList + Set sheetConf = CreateObject("Scripting.Dictionary") + sheetConf("StartRow") = 3 + sheetConf("KeyCol") = 15 + sheetConf("ValueCols") = Array(16) + Set sheetConfDict("errorList") = sheetConf + Debug.Print "RefreshSheetDict errorList ok." + + Debug.Print "RefreshSheetDict end." End Sub Public Function GetSheetConfig() As Object @@ -705,109 +573,16 @@ Public Function GetSheetConfig() As Object Set GetSheetConfig = sheetConfDict End Function -Public Function GetM1Cache() As Object - If m1Cache Is Nothing Then Call RefreshM1Cache - Set GetM1Cache = m1Cache -End Function +Public Function RefreshAllCache() As Boolean + + ' refresh + Dim refreshCacheNames As Variant + refreshCacheNames = Array("M1", "M1KukanDCache", "M2", "Z1", "Z2", "Z3", "Z4", "T1", "T2", "T3", "O1","O2") + Dim refreshCacheName As Variant + For Each refreshCacheName In refreshCacheNames + Call RefreshCache(refreshCacheName) + Next refreshCacheName -Public Function GetM1KukanDCache() As Object - If m1KukanDCache Is Nothing Then Call RefreshM1KukanDCache - Set GetM1KukanDCache = m1KukanDCache -End Function - -Public Function GetM2Cache() As Object - If m2Cache Is Nothing Then Call RefreshM2Cache - Set GetM2Cache = m2Cache -End Function - -Public Function GetZ1Cache() As Object - If z1Cache Is Nothing Then Call RefreshZ1Cache - Set GetZ1Cache = z1Cache -End Function - -Public Function GetZ2Cache() As Object - If z2Cache Is Nothing Then Call RefreshZ2Cache - Set GetZ2Cache = z2Cache -End Function - -Public Function GetZ3Cache() As Object - If z3Cache Is Nothing Then Call RefreshZ3Cache - Set GetZ3Cache = z3Cache -End Function - -Public Function GetZ4Cache() As Object - If z4Cache Is Nothing Then Call RefreshZ4Cache - Set GetZ4Cache = z4Cache -End Function - -Public Function GetT1Cache() As Object - If t1Cache Is Nothing Then Call RefreshT1Cache - Set GetT1Cache = t1Cache -End Function - -Public Function GetT2Cache() As Object - If t2Cache Is Nothing Then Call RefreshT2Cache - Set GetT2Cache = t2Cache -End Function - -Public Function GetT3Cache() As Object - If t3Cache Is Nothing Then Call RefreshT3Cache - Set GetT3Cache = t3Cache -End Function - -Public Function GetO1Cache() As Object - If o1Cache Is Nothing Then Call RefreshO1Cache - Set GetO1Cache = o1Cache -End Function - -Public Function GetO2Cache() As Object - If o2Cache Is Nothing Then Call RefreshO2Cache - Set GetO2Cache = o2Cache -End Function - -Public Function GetOufukuList() As Object - If oufukuList Is Nothing Then Call RefreshOufukuList - Set GetOufukuList = oufukuList -End Function - -Public Function GetKoutaiList() As Object - If koutaiList Is Nothing Then Call RefreshKoutaiList - Set GetKoutaiList = koutaiList -End Function - -Public Function GetHigaitouList() As Object - If higaitouList Is Nothing Then Call RefreshHigaitouList - Set GetHigaitouList = higaitouList -End Function - -Public Function GetTokubetu() As Object - If tokubetuList Is Nothing Then Call RefreshTokubetu - Set GetTokubetu = tokubetuList -End Function - -Public Function GetKenshuList() As Object - If kenshuList Is Nothing Then Call RefreshKenshuList - Set GetKenshuList = kenshuList -End Function - -Public Function GetErrorList() As Object - If errorList Is Nothing Then Call RefreshErrorList - Set GetErrorList = errorList -End Function - -Public Function RefreshCache() As Boolean - Call RefreshM1Cache - Call RefreshM1KukanDCache - Call RefreshM2Cache - Call RefreshZ1Cache - Call RefreshZ2Cache - Call RefreshZ3Cache - Call RefreshZ4Cache - Call RefreshT1Cache - Call RefreshT2Cache - Call RefreshT3Cache - Call RefreshO1Cache - Call RefreshO2Cache Call RefreshTokubetu Call RefreshOufukuList Call RefreshKoutaiList diff --git a/src/module/Common_Selector.bas b/src/module/Common_Selector.bas index 25adf9f..9299c78 100644 --- a/src/module/Common_Selector.bas +++ b/src/module/Common_Selector.bas @@ -17,7 +17,7 @@ Option Explicit ' Create transport (T) dropdown from Z1 cache Public Function BuildTransportList() - Dim z1Cache As Object: Set z1Cache = GetZ1Cache() + Dim z1Cache As Object: Set z1Cache = GetCache("Z1") Dim dropdownList As String Dim key As Variant @@ -36,7 +36,7 @@ End Function ' Create todoke (G) dropdown Public Function BuildTodokeList() - Dim z4Cache As Object: Set z4Cache = GetZ4Cache() + Dim z4Cache As Object: Set z4Cache = GetCache("Z4") Dim dropdownList As String Dim key As Variant @@ -54,7 +54,7 @@ End Function ' Create oufuku (M) dropdown Public Function BuildOufukuList() - Dim oufukuList As Object: Set oufukuList = GetOufukuList() + Dim oufukuList As Object: Set oufukuList = GetCache("oufukuList") Dim dropdownList As String Dim key As Variant @@ -72,7 +72,7 @@ End Function ' Create Koutai (N) dropdown Public Function BuildKoutaiList() - Dim koutaiList As Object: Set koutaiList = GetKoutaiList() + Dim koutaiList As Object: Set koutaiList = GetCache("koutaiList") Dim dropdownList As String Dim key As Variant @@ -90,7 +90,7 @@ End Function ' Create Kettei (AU) dropdown Public Function BuildKetteiList() - Dim z2Cache As Object: Set z2Cache = GetZ2Cache() + Dim z2Cache As Object: Set z2Cache = GetCache("Z2") Dim dropdownList As String Dim key As Variant @@ -108,7 +108,7 @@ End Function ' Create Higaitou (AW) dropdown Public Function BuildHigaitouList() - Dim higaitouList As Object: Set higaitouList = GetHigaitouList() + Dim higaitouList As Object: Set higaitouList = GetCache("higaitouList") Dim dropdownList As String Dim key As Variant @@ -126,7 +126,7 @@ End Function ' Create MonthAmountKbn (AX) dropdown Public Function BuildMonthAmountKbnList() - Dim z3Cache As Object: Set z3Cache = GetZ3Cache() + Dim z3Cache As Object: Set z3Cache = GetCache("Z3") Dim dropdownList As String Dim key As Variant @@ -144,7 +144,7 @@ End Function ' Create Kanshoku (BC) dropdown Public Function BuildKanshokuList() - Dim o2Cache As Object: Set o2Cache = GetO2Cache() + Dim o2Cache As Object: Set o2Cache = GetCache("O2") Dim dropdownList As String Dim key As Variant diff --git a/src/sheet/C1.cls b/src/sheet/C1.cls index 79edc73..5fe1d6f 100644 --- a/src/sheet/C1.cls +++ b/src/sheet/C1.cls @@ -72,6 +72,10 @@ End Function ' Event Handlers ' ============================================================ Private Sub Worksheet_Change(ByVal Target As Range) + + Dim HasHeaderEdit As Boolean: HasHeaderEdit = CheckHeaderEdit(Me, Target) + If HasHeaderEdit = True Then Exit Sub + Dim watchArea As Range With Me Set watchArea = Union( _ @@ -118,7 +122,7 @@ Private Sub Worksheet_Change(ByVal Target As Range) For Each cellG In Target Dim todoke As String: todoke = Trim(cellG.Value) If todoke <> "" Then - Dim z4Cache As Object: Set z4Cache = GetZ4Cache() + Dim z4Cache As Object: Set z4Cache = GetCache("Z4") Dim todokeCde As String: todokeCde = GetCode(todoke) If z4Cache.Exists(todokeCde) Then Dim cellH As Range: Set cellH = Me.Cells(cellG.Row, 8) @@ -274,7 +278,7 @@ End Sub ' Fill kukan info from M1 cache (key: kukan code, value: 7 elements) Private Sub FillKukanFromM1(ByVal rowNum As Long, ByVal idx As Long) - Dim m1Cache As Object: Set m1Cache = GetM1Cache() + Dim m1Cache As Object: Set m1Cache = GetCache("M1") Dim codeCol As Long: codeCol = KUKAN_CODE_COLS(idx) Dim transportCol As Long: transportCol = KUKAN_TRANSPORT_COLS(idx) @@ -309,7 +313,7 @@ End Sub ' triggered by c clomun cshainno input Private Sub CreateAddress1Dropdown(ByVal rowNum As Long) - Dim o1Cache As Object: Set o1Cache = GetO1Cache() + Dim o1Cache As Object: Set o1Cache = GetCache("O1") Dim empNo As String empNo = Trim(Me.Cells(rowNum, 3).Value) @@ -345,7 +349,7 @@ End Sub ' triggered by address1 select O1 cache Private Sub CreateAddress2Dropdown(ByVal rowNum As Long) - Dim o1Cache As Object: Set o1Cache = GetO1Cache() + Dim o1Cache As Object: Set o1Cache = GetCache("O1") Dim empNo As String empNo = Trim(Me.Cells(rowNum, 3).Value) @@ -399,7 +403,7 @@ End Sub ' Create station from dropdown from M1_KukanD cache Private Sub CreateFromStationDropdown(ByVal rowNum As Long, ByVal transportCol As Long, ByVal stationCol As Long) - Dim m1KukanDCache As Object: Set m1KukanDCache = GetM1KukanDCache() + Dim m1KukanDCache As Object: Set m1KukanDCache = GetCache("M1KukanDCache") Dim transport As String: transport = GetCode(Me.Cells(rowNum, transportCol).Value) If transport = "" Then Exit Sub @@ -431,8 +435,8 @@ End Sub ' Create Kenshu dropdown from ' Structure: { D: { F: [G] } } Private Sub CreateKenshuDropdown(ByVal rowNum As Long, ByVal idx As Long, ByVal kukanCode As String) - Dim kenshuList As Object: Set kenshuList = GetKenshuList() - Dim m2Cache As Object: Set m2Cache = GetM2Cache() + Dim kenshuList As Object: Set kenshuList = GetCache("kenshuList") + Dim m2Cache As Object: Set m2Cache = GetCache("M2") Dim ticketCol As Long: ticketCol = KUKAN_TICKET_COLS(idx) Me.Cells(rowNum, ticketCol).ClearContents @@ -464,7 +468,7 @@ End Sub ' Create destination dropdown from M1_KukanD cache ' Structure: { D: { F: [G] } } Private Sub CreateToStationDropdown(ByVal rowNum As Long, ByVal transportCol As Long, ByVal stationFromCol As Long, ByVal stationToCol As Long) - Dim m1KukanDCache As Object: Set m1KukanDCache = GetM1KukanDCache() + Dim m1KukanDCache As Object: Set m1KukanDCache = GetCache("M1KukanDCache") Dim transport As String: transport = GetCode(Me.Cells(rowNum, transportCol).Value) Dim stationFrom As String: stationFrom = GetCode(Me.Cells(rowNum, stationFromCol).Value) @@ -499,7 +503,7 @@ End Sub ' Find kukan code by transport + station_from + station_to (reverse lookup) Private Function FindKukanCodeByStation(ByVal rowNum As Long, ByVal transportCol As Long, ByVal stationFromCol As Long, ByVal stationToCol As Long) As String - Dim m1Cache As Object: Set m1Cache = GetM1Cache() + Dim m1Cache As Object: Set m1Cache = GetCache("M1") Dim transportKbn As String: transportKbn = GetCode(Trim(Me.Cells(rowNum, transportCol).Value)) Dim stationFrom As String: stationFrom = Trim(Me.Cells(rowNum, stationFromCol).Value) @@ -530,7 +534,7 @@ End Sub ' Create dropdown from M2 cache: get code (J) list for kukanCode + kanshu Private Sub CreateM2CodeDropdown(ByVal rowNum As Long, ByVal kukanCodeCol As Long, ByVal kanshuCol As Long, ByVal codeCol As Long) - Dim m2Cache As Object: Set m2Cache = GetM2Cache() + Dim m2Cache As Object: Set m2Cache = GetCache("M2") Dim kukanCode As String: kukanCode = Trim(Me.Cells(rowNum, kukanCodeCol).Value) Dim kanshuStr As String: kanshuStr = Trim(Me.Cells(rowNum, kanshuCol).Value) @@ -634,7 +638,7 @@ Public Sub Validate(ws As Worksheet, ByVal rowNum As Long, ByVal lastDataRow As ' validate CodeSelect ' G column [todoke Cde] Dim ColG As String: ColG = "G" - Dim z4Cache As Object: Set z4Cache = GetZ4Cache() + Dim z4Cache As Object: Set z4Cache = GetCache("Z4") Dim todokeCde As String: todokeCde = GetCode(Trim(Me.Cells(rowNum, ColG).Value)) If Not z4Cache.Exists(todokeCde) Then Me.Cells(rowNum, errorCol).Value = GetErrorMsg("E001", ColG & rowNum) @@ -643,7 +647,7 @@ Public Sub Validate(ws As Worksheet, ByVal rowNum As Long, ByVal lastDataRow As End If ' I column [address1 J column address2] - Dim o1Cache As Object: Set o1Cache = GetO1Cache() + Dim o1Cache As Object: Set o1Cache = GetCache("O1") Dim ColI As String: ColI = "I" Dim ColJ As String: ColJ = "J" Dim address1 As String: address1 = Trim(Me.Cells(rowNum, ColI).Value) @@ -687,7 +691,7 @@ Public Sub Validate(ws As Worksheet, ByVal rowNum As Long, ByVal lastDataRow As ' validate CodeSelect ' M column [oufuku] Dim ColM As String: ColM = "M" - Dim oufukuList As Object: Set oufukuList = GetOufukuList() + Dim oufukuList As Object: Set oufukuList = GetCache("oufukuList") Dim oufukuCde As String: oufukuCde = GetCode(Trim(Me.Cells(rowNum, ColM).Value)) If Not oufukuList.Exists(oufukuCde) Then Me.Cells(rowNum, errorCol).Value = GetErrorMsg("E001", ColM & rowNum) @@ -698,7 +702,7 @@ Public Sub Validate(ws As Worksheet, ByVal rowNum As Long, ByVal lastDataRow As ' validate CodeSelect ' N column [koutai] Dim ColN As String: ColN = "N" - Dim koutaiList As Object: Set koutaiList = GetKoutaiList() + Dim koutaiList As Object: Set koutaiList = GetCache("koutaiList") Dim koutaiCde As String: koutaiCde = GetCode(Trim(Me.Cells(rowNum, ColN).Value)) If Not koutaiList.Exists(koutaiCde) Then Me.Cells(rowNum, errorCol).Value = ColN & " column is invalid" @@ -707,8 +711,8 @@ Public Sub Validate(ws As Worksheet, ByVal rowNum As Long, ByVal lastDataRow As End If ' validate KUKAN_CODE_COLS (S, Z, AG, AN) and related columns - Dim m1Cache As Object: Set m1Cache = GetM1Cache() - Dim m2Cache As Object: Set m2Cache = GetM2Cache() + Dim m1Cache As Object: Set m1Cache = GetCache("M1") + Dim m2Cache As Object: Set m2Cache = GetCache("M2") Dim kukanCols As Variant kukanCols = Array(KUKAN_TRANSPORT_COLS, KUKAN_STATION_COLS, KUKAN_ARRIVAL_COLS, KUKAN_TICKET_COLS, KUKAN_CODE2_COLS, KUKAN_START_DAY_COLS) diff --git a/src/sheet/M1.cls b/src/sheet/M1.cls index 24d8cf3..b698f90 100644 --- a/src/sheet/M1.cls +++ b/src/sheet/M1.cls @@ -9,7 +9,7 @@ ' Create dropdown for L column Private Sub CreateEnumDropdown(ByVal rowNum As Long) - Dim tokubetuList As Object: Set tokubetuList = GetTokubetu() + Dim tokubetuList As Object: Set tokubetuList = GetCache("tokubetuList") ' Build dropdown list from tokubetuList Dim dropdownList As String dropdownList = "" @@ -36,6 +36,9 @@ End Sub ' Private Sub Worksheet_Change(ByVal Target As Range) + Dim HasHeaderEdit As Boolean: HasHeaderEdit = CheckHeaderEdit(Me, Target) + If HasHeaderEdit = True Then Exit Sub + ' === Column C changes: Create L column dropdown === If Target.Column = 3 And Target.Row >= 7 Then Dim cell As Range @@ -51,7 +54,7 @@ Private Sub Worksheet_Change(ByVal Target As Range) ' === Column D changes: Fill E column === If Target.Column = 4 And Target.Row >= 7 Then - Dim z1Cache As Object: Set z1Cache = GetZ1Cache() + Dim z1Cache As Object: Set z1Cache = GetCache("Z1") Dim cellD As Range For Each cellD In Target @@ -115,7 +118,7 @@ Private Sub Validate(ws As Worksheet, ByVal rowNum As Long, ByVal lastDataRow As End If ' Check D and E column in the cache - Dim z1Cache As Object: Set z1Cache = GetZ1Cache() + Dim z1Cache As Object: Set z1Cache = GetCache("Z1") Dim dValue As String: dValue = Trim(ws.Range("D" & rowNum).Value) Dim eValue As String: eValue = Trim(ws.Range("E" & rowNum).Value) @@ -143,7 +146,7 @@ Private Sub Validate(ws As Worksheet, ByVal rowNum As Long, ByVal lastDataRow As End If ' Check L column in the tokubetuList - Dim tokubetuList As Object: Set tokubetuList = GetTokubetu() + Dim tokubetuList As Object: Set tokubetuList = GetCache("tokubetuList") Dim lValue As String: lValue = Trim(ws.Range("L" & rowNum).Value) If Not tokubetuList.Exists(lValue) Then ws.Cells(rowNum, errorCol).Value = "L column does not exist." @@ -152,7 +155,7 @@ Private Sub Validate(ws As Worksheet, ByVal rowNum As Long, ByVal lastDataRow As End If ' Check if M2 uses this M1 kukan code - Dim m2Cache As Object: Set m2Cache = GetM2Cache() + Dim m2Cache As Object: Set m2Cache = GetCache("M2") If Not m2Cache.Exists(cValue) Then ws.Cells(rowNum, errorCol).Value = GetErrorMsg("W001", cValue) ws.Range("C" & rowNum).Interior.Color = RGB(255, 128, 0) diff --git a/src/sheet/M2.cls b/src/sheet/M2.cls index a268519..903fb46 100644 --- a/src/sheet/M2.cls +++ b/src/sheet/M2.cls @@ -8,6 +8,11 @@ ' - Validate ' ============================================================ Private Sub Worksheet_Change(ByVal Target As Range) + Dim HasHeaderEdit As Boolean: HasHeaderEdit = CheckHeaderEdit(Me, Target) + If HasHeaderEdit = True Then Exit Sub + + If Target.EntireRow.Address = Target.Address Then Exit Sub + Dim watchArea As Range With Me Set watchArea = Union( _ @@ -29,6 +34,7 @@ Private Sub Worksheet_Change(ByVal Target As Range) For Each cell In Target If Trim(cell.Value) = "" Then Call ClearRowData(Me, cell.Row) + GoTo Finally Else Call FillFromM1(cell.Row) End If @@ -95,11 +101,11 @@ Private Sub FillKFromJ(ByVal rowNum As Long) Dim cache As Object Select Case iValue Case "1" - Set cache = GetT1Cache() + Set cache = GetCache("T1") Case "2" - Set cache = GetT2Cache() + Set cache = GetCache("T2") Case "3" - Set cache = GetT3Cache() + Set cache = GetCache("T3") Case Else Exit Sub End Select @@ -145,14 +151,14 @@ Private Sub CreateJDropdown(ByVal rowNum As Long) Dim cache As Object Select Case iValue Case "1" - Set cache = GetT1Cache() + Set cache = GetCache("T1") Me.Range("O" & rowNum).Interior.Color = RGB(192, 192, 192) Me.Range("P" & rowNum).Interior.Color = RGB(192, 192, 192) Me.Range("Q" & rowNum).Interior.Color = RGB(192, 192, 192) Case "2" - Set cache = GetT2Cache() + Set cache = GetCache("T2") Case "3" - Set cache = GetT3Cache() + Set cache = GetCache("T3") Me.Range("N" & rowNum).Interior.Color = RGB(192, 192, 192) Me.Range("O" & rowNum).Interior.Color = RGB(192, 192, 192) Me.Range("P" & rowNum).Interior.Color = RGB(192, 192, 192) @@ -187,7 +193,7 @@ End Sub Private Sub FillFromM1(ByVal rowNum As Long) Set ws = Me - Dim m1Cache As Object: Set m1Cache = GetM1Cache() + Dim m1Cache As Object: Set m1Cache = GetCache("M1") Dim cValue As String: cValue = Trim(ws.Range("C" & rowNum).Value) ' Fill D, E, F, G, H columns from M1 cache @@ -223,9 +229,10 @@ End Sub Private Sub ClearRowData(ByVal ws As Worksheet, ByVal rowNum As Long) ' Clear from D column onwards - ws.Range(ws.Cells(rowNum, 4), ws.Cells(rowNum, 15)).ClearContents - ws.Cells(rowNum, 6).Validation.Delete - ws.Cells(rowNum, 19).ClearContents ' Q column error info + ws.Range(ws.Cells(rowNum, "D"), ws.Cells(rowNum, "R")).ClearContents + ws.Range(ws.Cells(rowNum, "C"), ws.Cells(rowNum, "R")).Interior.Color = vbWhite + ws.Cells(rowNum, "J").Validation.Delete + ws.Cells(rowNum, "S").ClearContents End Sub Public Sub Validate(ws As Worksheet, ByVal rowNum As Long, ByVal lastDataRow As Long) @@ -241,19 +248,19 @@ Public Sub Validate(ws As Worksheet, ByVal rowNum As Long, ByVal lastDataRow As clearRange.Interior.Color = vbWhite ' Check C column in the cache - Dim m1Cache As Object: Set m1Cache = GetM1Cache() + Dim m1Cache As Object: Set m1Cache = GetCache("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 + 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("I", "J", "K", "L", "M") @@ -277,7 +284,7 @@ Public Sub Validate(ws As Worksheet, ByVal rowNum As Long, ByVal lastDataRow As Next col ' Check I column in the kenshuKbn - Dim kenshuList As Object: Set kenshuList = GetKenshuList() + Dim kenshuList As Object: Set kenshuList = GetCache("kenshuList") 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) @@ -299,7 +306,7 @@ Public Sub Validate(ws As Worksheet, ByVal rowNum As Long, ByVal lastDataRow As Dim equaledCols As Variant Dim emptyCols As Variant If kenshuKbn = "1" Then - Set cache = GetT1Cache() + Set cache = GetCache("T1") ' must input equaledCols = Array("K") requiredCols = Array("N") @@ -307,7 +314,7 @@ Public Sub Validate(ws As Worksheet, ByVal rowNum As Long, ByVal lastDataRow As End If If kenshuKbn = "2" Then - Set cache = GetT2Cache() + Set cache = GetCache("T2") ' must input equaledCols = Array("K", "L", "M", "N", "O", "P", "Q") requiredCols = Array("N", "O", "P", "Q") @@ -315,7 +322,7 @@ Public Sub Validate(ws As Worksheet, ByVal rowNum As Long, ByVal lastDataRow As End If If kenshuKbn = "3" Then - Set cache = GetT3Cache() + Set cache = GetCache("T3") ' must input equaledCols = Array("K", "L", "M") requiredCols = Array() @@ -381,6 +388,13 @@ Public Sub Validate(ws As Worksheet, ByVal rowNum As Long, ByVal lastDataRow As End Sub -Sub ImportCSVAndTriggerChange(ws As Worksheet) - ' TODO +Public Sub ImportCSVAndTriggerChange(ws As Worksheet, ByVal lastDataRow As Long) + Dim sheetConfDict As Object: Set sheetConfDict = GetSheetConfig() + Dim sheetConf As Object: Set sheetConf = sheetConfDict(ws.CodeName) + + Dim startRow As Long: startRow = sheetConf("StartRow") + Dim i As Long + For i = startRow To lastDataRow + Call FillFromM1(i) + Next i End Sub diff --git a/src/sheet/T1.cls b/src/sheet/T1.cls index 12fbf98..3f6a911 100644 --- a/src/sheet/T1.cls +++ b/src/sheet/T1.cls @@ -39,9 +39,6 @@ Public Sub Validate(ws As Worksheet, ByVal rowNum As Long, ByVal lastDataRow As If checkResult = False Then Exit Sub ' E column check - checkResult = CheckRequired(ws, rowNum, 5, errorCol) - If checkResult = False Then Exit Sub - checkResult = CheckVarcharOver(ws, rowNum, 5, 80, errorCol) If checkResult = False Then Exit Sub diff --git a/src/sheet/T2.cls b/src/sheet/T2.cls index 6f156ce..34e98e4 100644 --- a/src/sheet/T2.cls +++ b/src/sheet/T2.cls @@ -39,9 +39,6 @@ Public Sub Validate(ws As Worksheet, ByVal rowNum As Long, ByVal lastDataRow As If checkResult = False Then Exit Sub ' E column check - checkResult = CheckRequired(ws, rowNum, 5, errorCol) - If checkResult = False Then Exit Sub - checkResult = CheckVarcharOver(ws, rowNum, 5, 80, errorCol) If checkResult = False Then Exit Sub diff --git a/src/sheet/T3.cls b/src/sheet/T3.cls index 877df96..7734b29 100644 --- a/src/sheet/T3.cls +++ b/src/sheet/T3.cls @@ -39,9 +39,6 @@ Public Sub Validate(ws As Worksheet, ByVal rowNum As Long, ByVal lastDataRow As If checkResult = False Then Exit Sub ' E column check - checkResult = CheckRequired(ws, rowNum, 5, errorCol) - If checkResult = False Then Exit Sub - checkResult = CheckVarcharOver(ws, rowNum, 5, 80, errorCol) If checkResult = False Then Exit Sub diff --git a/src/sheet/Z1.cls b/src/sheet/Z1.cls index 8ba642f..dd52124 100644 --- a/src/sheet/Z1.cls +++ b/src/sheet/Z1.cls @@ -41,9 +41,6 @@ Public Sub Validate(ws As Worksheet, ByVal rowNum As Long, ByVal lastDataRow As If checkResult = False Then Exit Sub ' E column check - checkResult = CheckRequired(ws, rowNum, 5, errorCol) - If checkResult = False Then Exit Sub - checkResult = CheckVarcharOver(ws, rowNum, 5, 80, errorCol) If checkResult = False Then Exit Sub diff --git a/src/sheet/Z2.cls b/src/sheet/Z2.cls index e09f2a0..4856c16 100644 --- a/src/sheet/Z2.cls +++ b/src/sheet/Z2.cls @@ -39,9 +39,6 @@ Public Sub Validate(ws As Worksheet, ByVal rowNum As Long, ByVal lastDataRow As If checkResult = False Then Exit Sub ' E column check - checkResult = CheckRequired(ws, rowNum, 5, errorCol) - If checkResult = False Then Exit Sub - checkResult = CheckVarcharOver(ws, rowNum, 5, 80, errorCol) If checkResult = False Then Exit Sub diff --git a/src/sheet/Z3.cls b/src/sheet/Z3.cls index 2e7abee..da071a7 100644 --- a/src/sheet/Z3.cls +++ b/src/sheet/Z3.cls @@ -38,9 +38,6 @@ Public Sub Validate(ws As Worksheet, ByVal rowNum As Long, ByVal lastDataRow As If checkResult = False Then Exit Sub ' E column check - checkResult = CheckRequired(ws, rowNum, 5, errorCol) - If checkResult = False Then Exit Sub - checkResult = CheckVarcharOver(ws, rowNum, 5, 80, errorCol) If checkResult = False Then Exit Sub diff --git a/src/sheet/Z4.cls b/src/sheet/Z4.cls index 7510867..5e1b185 100644 --- a/src/sheet/Z4.cls +++ b/src/sheet/Z4.cls @@ -38,9 +38,6 @@ Public Sub Validate(ws As Worksheet, ByVal rowNum As Long, ByVal lastDataRow As If checkResult = False Then Exit Sub ' E column check - checkResult = CheckRequired(ws, rowNum, 5, errorCol) - If checkResult = False Then Exit Sub - checkResult = CheckVarcharOver(ws, rowNum, 5, 80, errorCol) If checkResult = False Then Exit Sub diff --git a/通勤手当テンプレート_案.xlsm b/通勤手当テンプレート_案.xlsm index f453190..e71ca4b 100644 Binary files a/通勤手当テンプレート_案.xlsm and b/通勤手当テンプレート_案.xlsm differ