MartMartnz
New member
- Joined
- Nov 27, 2018
- Messages
- 3
- Reaction score
- 0
- Points
- 0
- Excel Version(s)
- 2016
Hello,
I am not an expert in VBA and I would appreciate some help with a problem I am trying to solve.
I have a column (B2:B14) where the users need to insert the delivery dates of various product, I would like to insert a VBA code to automatically check if the information inserted in column B has the Date format (dd-mm-yyyy), if the format is not correct the cell's fill colour change to red.
I adapted a code from the net, but the result is not the ideal, the blank cells also change the background to red.
Is possible to change the code in order to ignore the blank cells?
Any suggestions would be greatly appreciated
Thank you in advanced.
I am not an expert in VBA and I would appreciate some help with a problem I am trying to solve.
I have a column (B2:B14) where the users need to insert the delivery dates of various product, I would like to insert a VBA code to automatically check if the information inserted in column B has the Date format (dd-mm-yyyy), if the format is not correct the cell's fill colour change to red.
I adapted a code from the net, but the result is not the ideal, the blank cells also change the background to red.
HTML:
Private Sub DateFormat()
Dim myRange As RangeSet myRange = Range("B2:B14")
myRange.FormatConditions.Delete
myRange.FormatConditions.Add Type:=xlCellValue, Operator:=xlNotBetween, _ Formula1:="01-01-2020", Formula2:="31-12-2040"myRange.FormatConditions(1).Interior.Color = RGB(255, 0, 0)
End Sub
Is possible to change the code in order to ignore the blank cells?
Any suggestions would be greatly appreciated
Thank you in advanced.