refactor error

This commit is contained in:
updsv7
2026-04-21 12:24:49 +09:00
parent 6f2bb324e4
commit e2e115b7f4
9 changed files with 246 additions and 320 deletions

View File

@@ -5,7 +5,7 @@ Sub ImportModulesAndSheets_Safe()
Dim fso As Object Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject") 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 MODULE_PATH As String = PROJECT_PATH & "src\module"
Const SHEET_PATH As String = PROJECT_PATH & "src\sheet" Const SHEET_PATH As String = PROJECT_PATH & "src\sheet"

View File

@@ -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 errorMessage As String : errorMessage = Trim(ws.Cells(r, errorCol).Value)
Dim errorCode As String: errorCode = GetCode(errorMessage) Dim errorCode As String: errorCode = GetCode(errorMessage)
If errorCode <> "W001" And errorCode <> "" Then If errorCode <> "W001" And errorCode <> "" Then
MsgBox errorMessage
errorCountOut = errorCountOut + 1 errorCountOut = errorCountOut + 1
End If End If
Next r Next r

View File

@@ -320,11 +320,111 @@ Public Function FormatDateInput(ByVal inputStr As String) As String
End If End If
End Function 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 errorList As Object: Set errorList = GetErrorList()
Dim errorMessage As String Dim errorMessage As String
If errorList.Exists(errorCode) Then 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 End If
GetErrorMsg = errorMessage GetErrorMsg = errorMessage
End Function 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

View File

@@ -401,6 +401,7 @@ End Sub
' higaitouList ' higaitouList
' ============================================================ ' ============================================================
Private Sub RefreshErrorList() Private Sub RefreshErrorList()
Set errorList = Nothing
On Error GoTo RefreshError On Error GoTo RefreshError
Set errorList = LoadLookup("Enum", keyCol:=18, valueCols:=Array(19), startRow:=3) Set errorList = LoadLookup("Enum", keyCol:=18, valueCols:=Array(19), startRow:=3)
On Error GoTo 0 On Error GoTo 0

View File

@@ -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)) Dim clearRange As Range: Set clearRange = ws.Range(ws.Cells(rowNum, startCol), ws.Cells(rowNum, endCol))
clearRange.Interior.Color = vbWhite clearRange.Interior.Color = vbWhite
Dim cValue As String: cValue = Trim(ws.Cells(rowNum, 3).Value) Dim checkResult As Boolean: checkResult = False
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 ' C column check
ws.Cells(rowNum, errorCol).Value = "C column must be 3 characters" checkResult = CheckRequired(ws, rowNum, 3, errorCol)
ws.Cells(rowNum, 3).Interior.Color = RGB(255, 0, 0) If checkResult = False Then Exit Sub
Exit Sub
End If
Dim i As Long checkResult = CheckChar(ws, rowNum, 3, 3, errorCol)
Dim ch As String If checkResult = False Then Exit Sub
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 checkResult = CheckAlphanumeric(ws, rowNum, 3, 3, errorCol)
dValue = Trim(ws.Cells(rowNum, 4).Value) If checkResult = False Then Exit Sub
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 ' D column check
eValue = Trim(ws.Cells(rowNum, 5).Value) checkResult = CheckRequired(ws, rowNum, 4, errorCol)
If eValue = "" Then If checkResult = False Then Exit Sub
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 checkResult = CheckVarcharOver(ws, rowNum, 4, 80, errorCol)
fValue = Trim(ws.Cells(rowNum, 6).Value) If checkResult = False Then Exit Sub
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 ' E column check
gValue = Trim(ws.Cells(rowNum, 7).Value) checkResult = CheckRequired(ws, rowNum, 5, errorCol)
If gValue <> "" And Len(gValue) > 80 Then If checkResult = False Then Exit Sub
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 checkResult = CheckVarcharOver(ws, rowNum, 5, 80, errorCol)
hValue = Trim(ws.Cells(rowNum, 8).Value) If checkResult = False Then Exit Sub
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 iValue As String ' F column check
iValue = Trim(ws.Cells(rowNum, 9).Value) checkResult = CheckVarcharOver(ws, rowNum, 6, 80, errorCol)
If iValue <> "" And Len(iValue) > 80 Then If checkResult = False Then Exit Sub
ws.Cells(rowNum, errorCol).Value = "I column must be within 80 characters"
ws.Cells(rowNum, 9).Interior.Color = RGB(255, 0, 0) ' G column check
Exit Sub checkResult = CheckVarcharOver(ws, rowNum, 7, 80, errorCol)
End If 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 ws.Cells(rowNum, errorCol).ClearContents
End Sub End Sub

View File

@@ -18,78 +18,37 @@ 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)) Dim clearRange As Range: Set clearRange = ws.Range(ws.Cells(rowNum, startCol), ws.Cells(rowNum, endCol))
clearRange.Interior.Color = vbWhite clearRange.Interior.Color = vbWhite
Dim cValue As String: cValue = Trim(ws.Cells(rowNum, 3).Value) ' C column check
If cValue = "" Then checkResult = CheckRequired(ws, rowNum, 3, errorCol)
ws.Cells(rowNum, errorCol).Value = "C column is required" If checkResult = False Then Exit Sub
ws.Cells(rowNum, 3).Interior.Color = RGB(255, 0, 0)
Exit Sub
End If
If Len(cValue) <> 3 Then checkResult = CheckChar(ws, rowNum, 3, 1, errorCol)
ws.Cells(rowNum, errorCol).Value = "C column must be 3 characters" If checkResult = False Then Exit Sub
ws.Cells(rowNum, 3).Interior.Color = RGB(255, 0, 0)
Exit Sub
End If
Dim i As Long checkResult = CheckAlphanumeric(ws, rowNum, 3, 1, errorCol)
Dim ch As String If checkResult = False Then Exit Sub
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 ' D column check
dValue = Trim(ws.Cells(rowNum, 4).Value) checkResult = CheckRequired(ws, rowNum, 4, errorCol)
If dValue = "" Then If checkResult = False Then Exit Sub
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 checkResult = CheckVarcharOver(ws, rowNum, 4, 80, errorCol)
eValue = Trim(ws.Cells(rowNum, 5).Value) If checkResult = False Then Exit Sub
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 ' E column check
fValue = Trim(ws.Cells(rowNum, 6).Value) checkResult = CheckRequired(ws, rowNum, 5, errorCol)
If fValue <> "" And Len(fValue) > 80 Then If checkResult = False Then Exit Sub
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 checkResult = CheckVarcharOver(ws, rowNum, 5, 80, errorCol)
hValue = Trim(ws.Cells(rowNum, 7).Value) If checkResult = False Then Exit Sub
If hValue <> "" Then
If Len(hValue) <> 1 Then ' F column check
ws.Cells(rowNum, errorCol).Value = "G column must be 1 digit" checkResult = CheckVarcharOver(ws, rowNum, 6, 80, errorCol)
ws.Cells(rowNum, 7).Interior.Color = RGB(255, 0, 0) If checkResult = False Then Exit Sub
Exit Sub
End If ' G column check
If hValue <> "0" And hValue <> "1" Then checkResult = Check01(ws, rowNum, 7, errorCol)
ws.Cells(rowNum, errorCol).Value = "G column must be 0 or 1" If checkResult = False Then Exit Sub
ws.Cells(rowNum, 7).Interior.Color = RGB(255, 0, 0)
Exit Sub
End If
End If
ws.Cells(rowNum, errorCol).ClearContents ws.Cells(rowNum, errorCol).ClearContents
End Sub End Sub

View File

@@ -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)) Dim clearRange As Range: Set clearRange = ws.Range(ws.Cells(rowNum, startCol), ws.Cells(rowNum, endCol))
clearRange.Interior.Color = vbWhite clearRange.Interior.Color = vbWhite
Dim cValue As String: cValue = Trim(ws.Cells(rowNum, 3).Value) ' C column check
If cValue = "" Then checkResult = CheckRequired(ws, rowNum, 3, errorCol)
ws.Cells(rowNum, endCol).Value = "C column is required" If checkResult = False Then Exit Sub
ws.Cells(rowNum, 3).Interior.Color = RGB(255, 0, 0)
Exit Sub
End If
If Len(cValue) <> 3 Then checkResult = CheckChar(ws, rowNum, 3, 2, errorCol)
ws.Cells(rowNum, endCol).Value = "C column must be 3 characters" If checkResult = False Then Exit Sub
ws.Cells(rowNum, 3).Interior.Color = RGB(255, 0, 0)
Exit Sub
End If
Dim i As Long checkResult = CheckAlphanumeric(ws, rowNum, 3, 2, errorCol)
Dim ch As String If checkResult = False Then Exit Sub
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 ' D column check
dValue = Trim(ws.Cells(rowNum, 4).Value) checkResult = CheckRequired(ws, rowNum, 4, errorCol)
If dValue = "" Then If checkResult = False Then Exit Sub
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 checkResult = CheckVarcharOver(ws, rowNum, 4, 80, errorCol)
eValue = Trim(ws.Cells(rowNum, 5).Value) If checkResult = False Then Exit Sub
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 ' E column check
fValue = Trim(ws.Cells(rowNum, 6).Value) checkResult = CheckRequired(ws, rowNum, 5, errorCol)
If fValue <> "" And Len(fValue) > 80 Then If checkResult = False Then Exit Sub
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 checkResult = CheckVarcharOver(ws, rowNum, 5, 80, errorCol)
hValue = Trim(ws.Cells(rowNum, 7).Value) If checkResult = False Then Exit Sub
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
Dim iValue As String ' F column check
iValue = Trim(ws.Cells(rowNum, 8).Value) checkResult = CheckVarcharOver(ws, rowNum, 6, 80, errorCol)
If iValue <> "" And Len(iValue) > 80 Then If checkResult = False Then Exit Sub
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
ws.Cells(rowNum, endCol).ClearContents ' 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 End Sub

View File

@@ -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)) Dim clearRange As Range: Set clearRange = ws.Range(ws.Cells(rowNum, startCol), ws.Cells(rowNum, endCol))
clearRange.Interior.Color = vbWhite clearRange.Interior.Color = vbWhite
Dim cValue As String: cValue = Trim(ws.Cells(rowNum, 3).Value) ' C column check
If cValue = "" Then checkResult = CheckRequired(ws, rowNum, 3, errorCol)
ws.Cells(rowNum, errorCol).Value = "C column is required" If checkResult = False Then Exit Sub
ws.Cells(rowNum, 3).Interior.Color = RGB(255, 0, 0)
Exit Sub
End If
If Len(cValue) <> 3 Then checkResult = CheckChar(ws, rowNum, 3, 2, errorCol)
ws.Cells(rowNum, errorCol).Value = "C column must be 3 characters" If checkResult = False Then Exit Sub
ws.Cells(rowNum, 3).Interior.Color = RGB(255, 0, 0)
Exit Sub
End If
Dim i As Long checkResult = CheckAlphanumeric(ws, rowNum, 3, 2, errorCol)
Dim ch As String If checkResult = False Then Exit Sub
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 ' D column check
dValue = Trim(ws.Cells(rowNum, 4).Value) checkResult = CheckRequired(ws, rowNum, 4, errorCol)
If dValue = "" Then If checkResult = False Then Exit Sub
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 checkResult = CheckVarcharOver(ws, rowNum, 4, 80, errorCol)
eValue = Trim(ws.Cells(rowNum, 5).Value) If checkResult = False Then Exit Sub
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 ' E column check
fValue = Trim(ws.Cells(rowNum, 6).Value) checkResult = CheckRequired(ws, rowNum, 5, errorCol)
If fValue <> "" And Len(fValue) > 80 Then If checkResult = False Then Exit Sub
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 checkResult = CheckVarcharOver(ws, rowNum, 5, 80, errorCol)
hValue = Trim(ws.Cells(rowNum, 7).Value) If checkResult = False Then Exit Sub
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
Dim iValue As String ' F column check
iValue = Trim(ws.Cells(rowNum, 8).Value) checkResult = CheckVarcharOver(ws, rowNum, 6, 80, errorCol)
If iValue <> "" And Len(iValue) > 80 Then If checkResult = False Then Exit Sub
ws.Cells(rowNum, errorCol).Value = "H column must be within 80 characters"
ws.Cells(rowNum, 8).Interior.Color = RGB(255, 0, 0) ' G column check
Exit Sub checkResult = Check01(ws, rowNum, 7, errorCol)
End If 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 ws.Cells(rowNum, errorCol).ClearContents
End Sub End Sub