diff --git a/src/init_module/Import_modules.bas b/src/init_module/Import_modules.bas index 71db349..c90ced6 100644 --- a/src/init_module/Import_modules.bas +++ b/src/init_module/Import_modules.bas @@ -5,7 +5,7 @@ Sub ImportModulesAndSheets_Safe() Dim fso As Object Set fso = CreateObject("Scripting.FileSystemObject") - Const PROJECT_PATH As String = "E:\AI\project\updsv7\vba\" + Const PROJECT_PATH As String = "D:\Project\upds7\vba\" Const MODULE_PATH As String = PROJECT_PATH & "src\module" Const SHEET_PATH As String = PROJECT_PATH & "src\sheet" diff --git a/src/module/Common_Button.bas b/src/module/Common_Button.bas index a077022..fb184e6 100644 --- a/src/module/Common_Button.bas +++ b/src/module/Common_Button.bas @@ -284,7 +284,6 @@ private Function RunValidationSilent(ws As Worksheet, Optional ByRef errorCountO Dim errorMessage As String : errorMessage = Trim(ws.Cells(r, errorCol).Value) Dim errorCode As String: errorCode = GetCode(errorMessage) If errorCode <> "W001" And errorCode <> "" Then - MsgBox errorMessage errorCountOut = errorCountOut + 1 End If Next r diff --git a/src/module/Common_Functions.bas b/src/module/Common_Functions.bas index b56b293..f952e66 100644 --- a/src/module/Common_Functions.bas +++ b/src/module/Common_Functions.bas @@ -320,11 +320,111 @@ Public Function FormatDateInput(ByVal inputStr As String) As String End If End Function -Function GetErrorMsg(ByVal errorCode As String, Optional ByVal param As String = "") As String +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 errorMessage As String If errorList.Exists(errorCode) Then - errorMessage = MakeSelect(errorCode, Replace(errorList(errorCode)(0), "{0}", param)) + errorMessage = Replace(errorList(errorCode)(0), "{0}", param0) + errorMessage = Replace(errorMessage, "{1}", param1) + errorMessage = MakeSelect(errorCode, errorMessage) End If GetErrorMsg = errorMessage End Function + +Function ColLetter(colNum As Long) As String + ColLetter = Split(Cells(1, colNum).Address, "$")(1) +End Function + +Function CheckRequired(ByVal ws As Worksheet, ByVal rowNum As Long, ByVal colNum As Long, ByVal errorCol As String) As Boolean + Dim checkValue As String: checkValue = Trim(ws.Cells(rowNum, colNum).Value) + If checkValue = "" Then + Dim letter As String: letter = ColLetter(colNum) + ws.Cells(rowNum, errorCol).Value = GetErrorMsg("E002", letter & rowNum) + ws.Cells(rowNum, colNum).Interior.Color = RGB(255, 0, 0) + CheckRequired = False + Exit Function + End If + CheckRequired = True +End Function + +Function CheckChar(ByVal ws As Worksheet, ByVal rowNum As Long, ByVal colNum As Long, ByVal charLength As Long, ByVal errorCol As String) + Dim checkValue As String: checkValue = Trim(ws.Cells(rowNum, colNum).Value) + If Len(checkValue) <> charLength Then + Dim letter As String: letter = ColLetter(colNum) + ws.Cells(rowNum, errorCol).Value = GetErrorMsg("E006", letter & rowNum, charLength) + ws.Cells(rowNum, colNum).Interior.Color = RGB(255, 0, 0) + CheckChar = False + Exit Function + End If + CheckChar = True +End Function + +Function CheckAlphanumeric(ByVal ws As Worksheet, ByVal rowNum As Long, ByVal colNum As Long, ByVal charLength As Long, ByVal errorCol As String) + Dim checkValue As String: checkValue = Trim(ws.Cells(rowNum, colNum).Value) + Dim letter As String: letter = ColLetter(colNum) + Dim i As Long + Dim ch As String + For i = 1 To charLength + ch = Mid(checkValue, i, 1) + If Not ((ch >= "0" And ch <= "9") Or (ch >= "A" And ch <= "Z") Or (ch >= "a" And ch <= "z")) Then + ws.Cells(rowNum, errorCol).Value = GetErrorMsg("E005", letter & rowNum) + ws.Cells(rowNum, colNum).Interior.Color = RGB(255, 0, 0) + CheckAlphanumeric = False + Exit Function + End If + Next i + + CheckAlphanumeric = True +End Function + +Function CheckVarcharOver(ByVal ws As Worksheet, ByVal rowNum As Long, ByVal colNum As Long, ByVal varcharLength As Long, ByVal errorCol As String) + Dim checkValue As String: checkValue = Trim(ws.Cells(rowNum, colNum).Value) + If Len(checkValue) > varcharLength Then + Dim letter As String: letter = ColLetter(colNum) + ws.Cells(rowNum, errorCol).Value = GetErrorMsg("E007", letter & rowNum) + ws.Cells(rowNum, colNum).Interior.Color = RGB(255, 0, 0) + CheckVarcharOver = False + Exit Function + End If + CheckVarcharOver = True +End Function + +Function Check01(ByVal ws As Worksheet, ByVal rowNum As Long, ByVal colNum As Long, ByVal errorCol As String) + Dim checkValue As String: checkValue = Trim(ws.Cells(rowNum, colNum).Value) + Dim letter As String: letter = ColLetter(colNum) + If checkValue <> "" Then + If Len(checkValue) <> 1 Then + ws.Cells(rowNum, errorCol).Value = GetErrorMsg("E001", letter & rowNum) + ws.Cells(rowNum, colNum).Interior.Color = RGB(255, 0, 0) + Check01 = False + Exit Function + End If + If checkValue <> "0" And checkValue <> "1" Then + ws.Cells(rowNum, errorCol).Value = GetErrorMsg("E008", letter & rowNum) + ws.Cells(rowNum, colNum).Interior.Color = RGB(255, 0, 0) + Check01 = False + Exit Function + End If + End If + Check01 = True +End Function + +Function Check12(ByVal ws As Worksheet, ByVal rowNum As Long, ByVal colNum As Long, ByVal errorCol As String) + Dim checkValue As String: checkValue = Trim(ws.Cells(rowNum, colNum).Value) + Dim letter As String: letter = ColLetter(colNum) + If checkValue <> "" Then + If Len(checkValue) <> 1 Then + ws.Cells(rowNum, errorCol).Value = GetErrorMsg("E001", letter & rowNum) + ws.Cells(rowNum, colNum).Interior.Color = RGB(255, 0, 0) + Check12 = False + Exit Function + End If + If checkValue <> "1" And checkValue <> "2" Then + ws.Cells(rowNum, errorCol).Value = GetErrorMsg("E009", letter & rowNum) + ws.Cells(rowNum, colNum).Interior.Color = RGB(255, 0, 0) + Check12 = False + Exit Function + End If + End If + Check12 = True +End Function diff --git a/src/module/Common_Global_Cache.bas b/src/module/Common_Global_Cache.bas index a7f885b..e15304c 100644 --- a/src/module/Common_Global_Cache.bas +++ b/src/module/Common_Global_Cache.bas @@ -401,6 +401,7 @@ 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 diff --git a/src/sheet/Z1.cls b/src/sheet/Z1.cls index 2cd6efa..0e44d15 100644 --- a/src/sheet/Z1.cls +++ b/src/sheet/Z1.cls @@ -18,94 +18,47 @@ Public Sub Validate(ws As Worksheet, ByVal rowNum As Long, ByVal lastDataRow As Dim clearRange As Range: Set clearRange = ws.Range(ws.Cells(rowNum, startCol), ws.Cells(rowNum, endCol)) clearRange.Interior.Color = vbWhite - Dim cValue As String: cValue = Trim(ws.Cells(rowNum, 3).Value) - If cValue = "" Then - ws.Cells(rowNum, errorCol).Value = "C column is required" - ws.Cells(rowNum, 3).Interior.Color = RGB(255, 0, 0) - Exit Sub - End If - - If Len(cValue) <> 3 Then - ws.Cells(rowNum, errorCol).Value = "C column must be 3 characters" - ws.Cells(rowNum, 3).Interior.Color = RGB(255, 0, 0) - Exit Sub - End If - - Dim i As Long - Dim ch As String - For i = 1 To 3 - ch = Mid(cValue, i, 1) - If Not ((ch >= "0" And ch <= "9") Or (ch >= "A" And ch <= "Z") Or (ch >= "a" And ch <= "z")) Then - ws.Cells(rowNum, errorCol).Value = "C column must be alphanumeric" - ws.Cells(rowNum, 3).Interior.Color = RGB(255, 0, 0) - Exit Sub - End If - Next i - - Dim dValue As String - dValue = Trim(ws.Cells(rowNum, 4).Value) - If dValue = "" Then - ws.Cells(rowNum, errorCol).Value = "D column is required" - ws.Cells(rowNum, 4).Interior.Color = RGB(255, 0, 0) - Exit Sub - End If - If Len(dValue) > 80 Then - ws.Cells(rowNum, errorCol).Value = "D column must be within 80 characters" - ws.Cells(rowNum, 4).Interior.Color = RGB(255, 0, 0) - Exit Sub - End If - - Dim eValue As String - eValue = Trim(ws.Cells(rowNum, 5).Value) - If eValue = "" Then - ws.Cells(rowNum, errorCol).Value = "E column is required" - ws.Cells(rowNum, 5).Interior.Color = RGB(255, 0, 0) - Exit Sub - End If - If Len(eValue) > 80 Then - ws.Cells(rowNum, errorCol).Value = "E column must be within 80 characters" - ws.Cells(rowNum, 5).Interior.Color = RGB(255, 0, 0) - Exit Sub - End If - - Dim fValue As String - fValue = Trim(ws.Cells(rowNum, 6).Value) - If fValue <> "" And Len(fValue) > 80 Then - ws.Cells(rowNum, errorCol).Value = "F column must be within 80 characters" - ws.Cells(rowNum, 6).Interior.Color = RGB(255, 0, 0) - Exit Sub - End If - - Dim gValue As String - gValue = Trim(ws.Cells(rowNum, 7).Value) - If gValue <> "" And Len(gValue) > 80 Then - ws.Cells(rowNum, errorCol).Value = "G column must be within 80 characters" - ws.Cells(rowNum, 7).Interior.Color = RGB(255, 0, 0) - Exit Sub - End If - - Dim hValue As String - hValue = Trim(ws.Cells(rowNum, 8).Value) - If hValue <> "" Then - If Len(hValue) <> 1 Then - ws.Cells(rowNum, errorCol).Value = "H column must be 1 digit" - ws.Cells(rowNum, 8).Interior.Color = RGB(255, 0, 0) - Exit Sub - End If - If hValue <> "0" And hValue <> "1" Then - ws.Cells(rowNum, errorCol).Value = "H column must be 0 or 1" - ws.Cells(rowNum, 8).Interior.Color = RGB(255, 0, 0) - Exit Sub - End If - End If + Dim checkResult As Boolean: checkResult = False - Dim iValue As String - iValue = Trim(ws.Cells(rowNum, 9).Value) - If iValue <> "" And Len(iValue) > 80 Then - ws.Cells(rowNum, errorCol).Value = "I column must be within 80 characters" - ws.Cells(rowNum, 9).Interior.Color = RGB(255, 0, 0) - Exit Sub - End If + ' C column check + checkResult = CheckRequired(ws, rowNum, 3, errorCol) + If checkResult = False Then Exit Sub + + checkResult = CheckChar(ws, rowNum, 3, 3, errorCol) + If checkResult = False Then Exit Sub + + checkResult = CheckAlphanumeric(ws, rowNum, 3, 3, errorCol) + If checkResult = False Then Exit Sub + ' D column check + checkResult = CheckRequired(ws, rowNum, 4, errorCol) + If checkResult = False Then Exit Sub + + checkResult = CheckVarcharOver(ws, rowNum, 4, 80, errorCol) + 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 + + ' F column check + checkResult = CheckVarcharOver(ws, rowNum, 6, 80, errorCol) + If checkResult = False Then Exit Sub + + ' G column check + checkResult = CheckVarcharOver(ws, rowNum, 7, 80, errorCol) + If checkResult = False Then Exit Sub + + ' H column check + checkResult = Check01(ws, rowNum, 8, errorCol) + If checkResult = False Then Exit Sub + + ' I column check + checkResult = CheckVarcharOver(ws, rowNum, 9, 80, errorCol) + If checkResult = False Then Exit Sub + ws.Cells(rowNum, errorCol).ClearContents End Sub diff --git a/src/sheet/Z2.cls b/src/sheet/Z2.cls index 54ca388..a3ffab0 100644 --- a/src/sheet/Z2.cls +++ b/src/sheet/Z2.cls @@ -17,79 +17,38 @@ Public Sub Validate(ws As Worksheet, ByVal rowNum As Long, ByVal lastDataRow As ' clear C~I columns background color Dim clearRange As Range: Set clearRange = ws.Range(ws.Cells(rowNum, startCol), ws.Cells(rowNum, endCol)) clearRange.Interior.Color = vbWhite + + ' C column check + checkResult = CheckRequired(ws, rowNum, 3, errorCol) + If checkResult = False Then Exit Sub + + checkResult = CheckChar(ws, rowNum, 3, 1, errorCol) + If checkResult = False Then Exit Sub + + checkResult = CheckAlphanumeric(ws, rowNum, 3, 1, errorCol) + If checkResult = False Then Exit Sub - Dim cValue As String: cValue = Trim(ws.Cells(rowNum, 3).Value) - If cValue = "" Then - ws.Cells(rowNum, errorCol).Value = "C column is required" - ws.Cells(rowNum, 3).Interior.Color = RGB(255, 0, 0) - Exit Sub - End If + ' D column check + checkResult = CheckRequired(ws, rowNum, 4, errorCol) + If checkResult = False Then Exit Sub + + checkResult = CheckVarcharOver(ws, rowNum, 4, 80, errorCol) + 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 - If Len(cValue) <> 3 Then - ws.Cells(rowNum, errorCol).Value = "C column must be 3 characters" - ws.Cells(rowNum, 3).Interior.Color = RGB(255, 0, 0) - Exit Sub - End If + ' F column check + checkResult = CheckVarcharOver(ws, rowNum, 6, 80, errorCol) + If checkResult = False Then Exit Sub - Dim i As Long - Dim ch As String - For i = 1 To 3 - ch = Mid(cValue, i, 1) - If Not ((ch >= "0" And ch <= "9") Or (ch >= "A" And ch <= "Z") Or (ch >= "a" And ch <= "z")) Then - ws.Cells(rowNum, errorCol).Value = "C column must be alphanumeric" - ws.Cells(rowNum, 3).Interior.Color = RGB(255, 0, 0) - Exit Sub - End If - Next i - - Dim dValue As String - dValue = Trim(ws.Cells(rowNum, 4).Value) - If dValue = "" Then - ws.Cells(rowNum, errorCol).Value = "D column is required" - ws.Cells(rowNum, 4).Interior.Color = RGB(255, 0, 0) - Exit Sub - End If - If Len(dValue) > 80 Then - ws.Cells(rowNum, errorCol).Value = "D column must be within 80 characters" - ws.Cells(rowNum, 4).Interior.Color = RGB(255, 0, 0) - Exit Sub - End If - - Dim eValue As String - eValue = Trim(ws.Cells(rowNum, 5).Value) - If eValue = "" Then - ws.Cells(rowNum, errorCol).Value = "E column is required" - ws.Cells(rowNum, 5).Interior.Color = RGB(255, 0, 0) - Exit Sub - End If - If Len(eValue) > 80 Then - ws.Cells(rowNum, errorCol).Value = "E column must be within 80 characters" - ws.Cells(rowNum, 5).Interior.Color = RGB(255, 0, 0) - Exit Sub - End If - - Dim fValue As String - fValue = Trim(ws.Cells(rowNum, 6).Value) - If fValue <> "" And Len(fValue) > 80 Then - ws.Cells(rowNum, errorCol).Value = "F column must be within 80 characters" - ws.Cells(rowNum, 6).Interior.Color = RGB(255, 0, 0) - Exit Sub - End If - - Dim hValue As String - hValue = Trim(ws.Cells(rowNum, 7).Value) - If hValue <> "" Then - If Len(hValue) <> 1 Then - ws.Cells(rowNum, errorCol).Value = "G column must be 1 digit" - ws.Cells(rowNum, 7).Interior.Color = RGB(255, 0, 0) - Exit Sub - End If - If hValue <> "0" And hValue <> "1" Then - ws.Cells(rowNum, errorCol).Value = "G column must be 0 or 1" - ws.Cells(rowNum, 7).Interior.Color = RGB(255, 0, 0) - Exit Sub - End If - End If + ' G column check + checkResult = Check01(ws, rowNum, 7, errorCol) + If checkResult = False Then Exit Sub ws.Cells(rowNum, errorCol).ClearContents End Sub diff --git a/src/sheet/Z3.cls b/src/sheet/Z3.cls index d1abc0c..e58699f 100644 --- a/src/sheet/Z3.cls +++ b/src/sheet/Z3.cls @@ -17,86 +17,41 @@ Public Sub Validate(ws As Worksheet, ByVal rowNum As Long, ByVal lastDataRow As Dim clearRange As Range: Set clearRange = ws.Range(ws.Cells(rowNum, startCol), ws.Cells(rowNum, endCol)) clearRange.Interior.Color = vbWhite - Dim cValue As String: cValue = Trim(ws.Cells(rowNum, 3).Value) - If cValue = "" Then - ws.Cells(rowNum, endCol).Value = "C column is required" - ws.Cells(rowNum, 3).Interior.Color = RGB(255, 0, 0) - Exit Sub - End If - - If Len(cValue) <> 3 Then - ws.Cells(rowNum, endCol).Value = "C column must be 3 characters" - ws.Cells(rowNum, 3).Interior.Color = RGB(255, 0, 0) - Exit Sub - End If - - Dim i As Long - Dim ch As String - For i = 1 To 3 - ch = Mid(cValue, i, 1) - If Not ((ch >= "0" And ch <= "9") Or (ch >= "A" And ch <= "Z") Or (ch >= "a" And ch <= "z")) Then - ws.Cells(rowNum, endCol).Value = "C column must be alphanumeric" - ws.Cells(rowNum, 3).Interior.Color = RGB(255, 0, 0) - Exit Sub - End If - Next i - - Dim dValue As String - dValue = Trim(ws.Cells(rowNum, 4).Value) - If dValue = "" Then - ws.Cells(rowNum, endCol).Value = "D column is required" - ws.Cells(rowNum, 4).Interior.Color = RGB(255, 0, 0) - Exit Sub - End If - If Len(dValue) > 80 Then - ws.Cells(rowNum, endCol).Value = "D column must be within 80 characters" - ws.Cells(rowNum, 4).Interior.Color = RGB(255, 0, 0) - Exit Sub - End If - - Dim eValue As String - eValue = Trim(ws.Cells(rowNum, 5).Value) - If eValue = "" Then - ws.Cells(rowNum, endCol).Value = "E column is required" - ws.Cells(rowNum, 5).Interior.Color = RGB(255, 0, 0) - Exit Sub - End If - If Len(eValue) > 80 Then - ws.Cells(rowNum, endCol).Value = "E column must be within 80 characters" - ws.Cells(rowNum, 5).Interior.Color = RGB(255, 0, 0) - Exit Sub - End If - - Dim fValue As String - fValue = Trim(ws.Cells(rowNum, 6).Value) - If fValue <> "" And Len(fValue) > 80 Then - ws.Cells(rowNum, endCol).Value = "F column must be within 80 characters" - ws.Cells(rowNum, 6).Interior.Color = RGB(255, 0, 0) - Exit Sub - End If - - Dim hValue As String - hValue = Trim(ws.Cells(rowNum, 7).Value) - If hValue <> "" Then - If Len(hValue) <> 1 Then - ws.Cells(rowNum, endCol).Value = "G column must be 1 digit" - ws.Cells(rowNum, 7).Interior.Color = RGB(255, 0, 0) - Exit Sub - End If - If hValue <> "0" And hValue <> "1" Then - ws.Cells(rowNum, endCol).Value = "G column must be 0 or 1" - ws.Cells(rowNum, 7).Interior.Color = RGB(255, 0, 0) - Exit Sub - End If - End If + ' C column check + checkResult = CheckRequired(ws, rowNum, 3, errorCol) + If checkResult = False Then Exit Sub - Dim iValue As String - iValue = Trim(ws.Cells(rowNum, 8).Value) - If iValue <> "" And Len(iValue) > 80 Then - ws.Cells(rowNum, endCol).Value = "H column must be within 80 characters" - ws.Cells(rowNum, 8).Interior.Color = RGB(255, 0, 0) - Exit Sub - End If + checkResult = CheckChar(ws, rowNum, 3, 2, errorCol) + If checkResult = False Then Exit Sub + + checkResult = CheckAlphanumeric(ws, rowNum, 3, 2, errorCol) + If checkResult = False Then Exit Sub - ws.Cells(rowNum, endCol).ClearContents + ' D column check + checkResult = CheckRequired(ws, rowNum, 4, errorCol) + If checkResult = False Then Exit Sub + + checkResult = CheckVarcharOver(ws, rowNum, 4, 80, errorCol) + 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 + + ' F column check + checkResult = CheckVarcharOver(ws, rowNum, 6, 80, errorCol) + If checkResult = False Then Exit Sub + + ' G column check + checkResult = Check01(ws, rowNum, 7, errorCol) + If checkResult = False Then Exit Sub + + ' H column check + checkResult = CheckVarcharOver(ws, rowNum, 8, 80, errorCol) + If checkResult = False Then Exit Sub + + ws.Cells(rowNum, errorCol).ClearContents End Sub diff --git a/src/sheet/Z4.cls b/src/sheet/Z4.cls index 8dd6531..16b122b 100644 --- a/src/sheet/Z4.cls +++ b/src/sheet/Z4.cls @@ -17,86 +17,45 @@ Public Sub Validate(ws As Worksheet, ByVal rowNum As Long, ByVal lastDataRow As Dim clearRange As Range: Set clearRange = ws.Range(ws.Cells(rowNum, startCol), ws.Cells(rowNum, endCol)) clearRange.Interior.Color = vbWhite - Dim cValue As String: cValue = Trim(ws.Cells(rowNum, 3).Value) - If cValue = "" Then - ws.Cells(rowNum, errorCol).Value = "C column is required" - ws.Cells(rowNum, 3).Interior.Color = RGB(255, 0, 0) - Exit Sub - End If - - If Len(cValue) <> 3 Then - ws.Cells(rowNum, errorCol).Value = "C column must be 3 characters" - ws.Cells(rowNum, 3).Interior.Color = RGB(255, 0, 0) - Exit Sub - End If - - Dim i As Long - Dim ch As String - For i = 1 To 3 - ch = Mid(cValue, i, 1) - If Not ((ch >= "0" And ch <= "9") Or (ch >= "A" And ch <= "Z") Or (ch >= "a" And ch <= "z")) Then - ws.Cells(rowNum, errorCol).Value = "C column must be alphanumeric" - ws.Cells(rowNum, 3).Interior.Color = RGB(255, 0, 0) - Exit Sub - End If - Next i - - Dim dValue As String - dValue = Trim(ws.Cells(rowNum, 4).Value) - If dValue = "" Then - ws.Cells(rowNum, errorCol).Value = "D column is required" - ws.Cells(rowNum, 4).Interior.Color = RGB(255, 0, 0) - Exit Sub - End If - If Len(dValue) > 80 Then - ws.Cells(rowNum, errorCol).Value = "D column must be within 80 characters" - ws.Cells(rowNum, 4).Interior.Color = RGB(255, 0, 0) - Exit Sub - End If - - Dim eValue As String - eValue = Trim(ws.Cells(rowNum, 5).Value) - If eValue = "" Then - ws.Cells(rowNum, errorCol).Value = "E column is required" - ws.Cells(rowNum, 5).Interior.Color = RGB(255, 0, 0) - Exit Sub - End If - If Len(eValue) > 80 Then - ws.Cells(rowNum, errorCol).Value = "E column must be within 80 characters" - ws.Cells(rowNum, 5).Interior.Color = RGB(255, 0, 0) - Exit Sub - End If - - Dim fValue As String - fValue = Trim(ws.Cells(rowNum, 6).Value) - If fValue <> "" And Len(fValue) > 80 Then - ws.Cells(rowNum, errorCol).Value = "F column must be within 80 characters" - ws.Cells(rowNum, 6).Interior.Color = RGB(255, 0, 0) - Exit Sub - End If - - Dim hValue As String - hValue = Trim(ws.Cells(rowNum, 7).Value) - If hValue <> "" Then - If Len(hValue) <> 1 Then - ws.Cells(rowNum, errorCol).Value = "G column must be 1 digit" - ws.Cells(rowNum, 7).Interior.Color = RGB(255, 0, 0) - Exit Sub - End If - If hValue <> "0" And hValue <> "1" Then - ws.Cells(rowNum, errorCol).Value = "G column must be 0 or 1" - ws.Cells(rowNum, 7).Interior.Color = RGB(255, 0, 0) - Exit Sub - End If - End If + ' C column check + checkResult = CheckRequired(ws, rowNum, 3, errorCol) + If checkResult = False Then Exit Sub - Dim iValue As String - iValue = Trim(ws.Cells(rowNum, 8).Value) - If iValue <> "" And Len(iValue) > 80 Then - ws.Cells(rowNum, errorCol).Value = "H column must be within 80 characters" - ws.Cells(rowNum, 8).Interior.Color = RGB(255, 0, 0) - Exit Sub - End If + checkResult = CheckChar(ws, rowNum, 3, 2, errorCol) + If checkResult = False Then Exit Sub + + checkResult = CheckAlphanumeric(ws, rowNum, 3, 2, errorCol) + If checkResult = False Then Exit Sub + + ' D column check + checkResult = CheckRequired(ws, rowNum, 4, errorCol) + If checkResult = False Then Exit Sub + + checkResult = CheckVarcharOver(ws, rowNum, 4, 80, errorCol) + 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 + + ' F column check + checkResult = CheckVarcharOver(ws, rowNum, 6, 80, errorCol) + If checkResult = False Then Exit Sub + + ' G column check + checkResult = Check01(ws, rowNum, 7, errorCol) + If checkResult = False Then Exit Sub + + ' H column check + checkResult = CheckVarcharOver(ws, rowNum, 8, 80, errorCol) + If checkResult = False Then Exit Sub + + ' I column check + checkResult = Check12(ws, rowNum, 9, errorCol) + If checkResult = False Then Exit Sub ws.Cells(rowNum, errorCol).ClearContents End Sub diff --git a/通勤手当テンプレート_案.xlsm b/通勤手当テンプレート_案.xlsm index af43372..0ce4a22 100644 Binary files a/通勤手当テンプレート_案.xlsm and b/通勤手当テンプレート_案.xlsm differ