通勤認定エクセルツール対応16
This commit is contained in:
@@ -433,154 +433,3 @@ End Function
|
||||
Function ColNum(colLetter As String) As Long
|
||||
ColNum = Range(colLetter & "1").Column
|
||||
End Function
|
||||
|
||||
'Check required field is not empty
|
||||
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
|
||||
|
||||
'Check character length
|
||||
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
|
||||
|
||||
'Check alphanumeric characters
|
||||
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
|
||||
|
||||
'Check varchar length overflow
|
||||
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
|
||||
|
||||
'Check number length overflow
|
||||
Function CheckNumberOver(ByVal ws As Worksheet, ByVal rowNum As Long, ByVal colNum As Long, ByVal numberLength As Long, ByVal errorCol As String)
|
||||
Dim checkValue As String: checkValue = Trim(ws.Cells(rowNum, colNum).Value)
|
||||
If Len(checkValue) > numberLength Then
|
||||
Dim letter As String: letter = ColLetter(colNum)
|
||||
ws.Cells(rowNum, errorCol).Value = GetErrorMsg("E014", letter & rowNum, numberLength)
|
||||
ws.Cells(rowNum, colNum).Interior.Color = RGB(255, 0, 0)
|
||||
CheckNumberOver = False
|
||||
Exit Function
|
||||
End If
|
||||
CheckNumberOver = True
|
||||
End Function
|
||||
|
||||
'Check value is 0 or 1
|
||||
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
|
||||
|
||||
'Check value is 1 or 2
|
||||
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
|
||||
|
||||
'Check duplicate value in column
|
||||
Function CheckDuplicate(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)
|
||||
Dim letter As String: letter = ColLetter(colNum)
|
||||
Dim i As Long
|
||||
|
||||
For i = 7 To rowNum - 1
|
||||
If Trim(ws.Cells(i, colNum).Value) = checkValue Then
|
||||
ws.Cells(rowNum, errorCol).Value = GetErrorMsg("E010", letter & rowNum, checkValue)
|
||||
ws.Cells(rowNum, colNum).Interior.Color = RGB(255, 0, 0)
|
||||
CheckDuplicate = False
|
||||
Exit Function
|
||||
End If
|
||||
Next i
|
||||
|
||||
CheckDuplicate = True
|
||||
End Function
|
||||
|
||||
'Check numeric value
|
||||
Function CheckNumber(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)
|
||||
Dim letter As String: letter = ColLetter(colNum)
|
||||
|
||||
If checkValue = "" Then
|
||||
CheckNumber = True
|
||||
Exit Function
|
||||
End If
|
||||
|
||||
If Not IsNumeric(checkValue) Then
|
||||
ws.Cells(rowNum, errorCol).Value = GetErrorMsg("E011", letter & rowNum)
|
||||
ws.Cells(rowNum, colNum).Interior.Color = RGB(255, 0, 0)
|
||||
CheckNumber = False
|
||||
Exit Function
|
||||
End If
|
||||
|
||||
CheckNumber = True
|
||||
End Function
|
||||
|
||||
@@ -14,4 +14,15 @@ Public Const ValRule_Char As Long = 6
|
||||
Public Const ValRule_Varchar As Long = 7
|
||||
Public Const ValRule_Check01 As Long = 8
|
||||
Public Const ValRule_Alphanumeric As Long = 9
|
||||
Public Const ValRule_Custom As Long = 11
|
||||
Public Const ValRule_Custom As Long = 11
|
||||
|
||||
' --- Error Codes ---
|
||||
Public Const ERR_REQUIRED As String = "E002"
|
||||
Public Const ERR_INVALID As String = "E001"
|
||||
Public Const ERR_RANGE As String = "E004"
|
||||
Public Const ERR_NOT_EXIST As String = "E004"
|
||||
Public Const ERR_DUPLICATE As String = "E010"
|
||||
Public Const ERR_CHARLEN As String = "E006"
|
||||
Public Const ERR_VARLEN As String = "E007"
|
||||
Public Const ERR_CHECK01 As String = "E008"
|
||||
Public Const ERR_NUMDIGITS As String = "E014"
|
||||
Reference in New Issue
Block a user