У меня проблема с этим кодом здесь. Он распознает 12/05/2020
и 2020/05/12
как не dd/mm/yyyy
, какое-либо решение?
Sub checkDateFormat()
Call declareVars
Dim rng As Range
Dim colStartCell As Range
Dim colEndCell As Range
Dim cNum As Integer
Dim dateFormat As String
Dim n As Integer
n = 0
For Each Cell In g_validationRange
If 0 < InStr(UCase(Cell), UCase(C_CHECKDATE_KW)) Then
cNum = Cell.Column
Set colStartCell = Cells(g_firstDataRangeRow, cNum)
'MsgBox colStartCell.Address
Set colEndCell = Cells(g_dataLastRowNum, cNum)
'MsgBox colEndCell.Address
Set rng = Range(colStartCell, colEndCell)
cellArray = splitArray(Cell)
Set cellCollection = validationCheck(cellArray, C_CHECKDATE_KW)
dateFormat = cellCollection(1)
n = 0
For Each repcell In rng
reqDate = CDate(repcell.Value)
'MsgBox collContains(cellCollection, repcell.Value)
If repcell.NumberFormat <> dateFormat Then
n = n + 1
repcell.Interior.ColorIndex = 37
End If
Next repcell
End If
Next Cell
If n <> 0 Then
MsgBox "Please use the dd/mm/yyyy date format in " & n & " cells highlighted under " & Cells(g_attrFirstRowNum, cNum)
End If
End Sub