Update Z1 validation - D,E required within 80 chars, F,G,I optional within 80 chars, H optional 0 or 1
This commit is contained in:
@@ -165,17 +165,80 @@ Sub validateDetailData(ByVal ws As Worksheet, ByVal rowNum As Long)
|
|||||||
Exit Sub
|
Exit Sub
|
||||||
End If
|
End If
|
||||||
|
|
||||||
If Not IsNumeric(cValue) And Len(cValue) = 3 Then
|
Dim i As Long
|
||||||
' Check if all characters are alphanumeric
|
Dim ch As String
|
||||||
Dim i As Long
|
For i = 1 To 3
|
||||||
Dim ch As String
|
ch = Mid(cValue, i, 1)
|
||||||
For i = 1 To 3
|
If Not ((ch >= "0" And ch <= "9") Or (ch >= "A" And ch <= "Z") Or (ch >= "a" And ch <= "z")) Then
|
||||||
ch = Mid(cValue, i, 1)
|
ws.Cells(rowNum, 2).Value = "C column must be alphanumeric"
|
||||||
If Not ((ch >= "0" And ch <= "9") Or (ch >= "A" And ch <= "Z") Or (ch >= "a" And ch <= "z")) Then
|
Exit Sub
|
||||||
ws.Cells(rowNum, 2).Value = "C column must be alphanumeric"
|
End If
|
||||||
Exit Sub
|
Next i
|
||||||
End If
|
|
||||||
Next i
|
' Check D column - must be within 80 full-width characters, required
|
||||||
|
Dim dValue As String
|
||||||
|
dValue = Trim(ws.Cells(rowNum, 4).Value)
|
||||||
|
|
||||||
|
If dValue = "" Then
|
||||||
|
ws.Cells(rowNum, 2).Value = "D column is required"
|
||||||
|
Exit Sub
|
||||||
|
End If
|
||||||
|
|
||||||
|
If Len(dValue) > 80 Then
|
||||||
|
ws.Cells(rowNum, 2).Value = "D column must be within 80 characters"
|
||||||
|
Exit Sub
|
||||||
|
End If
|
||||||
|
|
||||||
|
' Check E column - must be within 80 full-width characters, required
|
||||||
|
Dim eValue As String
|
||||||
|
eValue = Trim(ws.Cells(rowNum, 5).Value)
|
||||||
|
|
||||||
|
If eValue = "" Then
|
||||||
|
ws.Cells(rowNum, 2).Value = "E column is required"
|
||||||
|
Exit Sub
|
||||||
|
End If
|
||||||
|
|
||||||
|
If Len(eValue) > 80 Then
|
||||||
|
ws.Cells(rowNum, 2).Value = "E column must be within 80 characters"
|
||||||
|
Exit Sub
|
||||||
|
End If
|
||||||
|
|
||||||
|
' Check F column - must be within 80 full-width characters, optional
|
||||||
|
Dim fValue As String
|
||||||
|
fValue = Trim(ws.Cells(rowNum, 6).Value)
|
||||||
|
If fValue <> "" And Len(fValue) > 80 Then
|
||||||
|
ws.Cells(rowNum, 2).Value = "F column must be within 80 characters"
|
||||||
|
Exit Sub
|
||||||
|
End If
|
||||||
|
|
||||||
|
' Check G column - must be within 80 full-width characters, optional
|
||||||
|
Dim gValue As String
|
||||||
|
gValue = Trim(ws.Cells(rowNum, 7).Value)
|
||||||
|
If gValue <> "" And Len(gValue) > 80 Then
|
||||||
|
ws.Cells(rowNum, 2).Value = "G column must be within 80 characters"
|
||||||
|
Exit Sub
|
||||||
|
End If
|
||||||
|
|
||||||
|
' Check I column - must be within 80 full-width characters, optional
|
||||||
|
Dim iValue As String
|
||||||
|
iValue = Trim(ws.Cells(rowNum, 9).Value)
|
||||||
|
If iValue <> "" And Len(iValue) > 80 Then
|
||||||
|
ws.Cells(rowNum, 2).Value = "I column must be within 80 characters"
|
||||||
|
Exit Sub
|
||||||
|
End If
|
||||||
|
|
||||||
|
' Check H column - 1 digit, 0 or 1, optional
|
||||||
|
Dim hValue As String
|
||||||
|
hValue = Trim(ws.Cells(rowNum, 8).Value)
|
||||||
|
If hValue <> "" Then
|
||||||
|
If Len(hValue) <> 1 Then
|
||||||
|
ws.Cells(rowNum, 2).Value = "H column must be 1 digit"
|
||||||
|
Exit Sub
|
||||||
|
End If
|
||||||
|
If hValue <> "0" And hValue <> "1" Then
|
||||||
|
ws.Cells(rowNum, 2).Value = "H column must be 0 or 1"
|
||||||
|
Exit Sub
|
||||||
|
End If
|
||||||
End If
|
End If
|
||||||
|
|
||||||
' Validation passed
|
' Validation passed
|
||||||
|
|||||||
Reference in New Issue
Block a user