Hi,
I need to validate yyyy.mm.dd for a cell in excel using vba code
Hi
The expression be like this
Inside the FOR EACH ROW loop
Use a IF condition like this
DateTime.TryParseExact(datestring,”yyyy.MM.dd”, System.Globalization.CultureInfo.InvariantCulture, Globalization.DateTimeStyles.None, Nothing)
Which will return a Boolean output
Cheers @raghuramk
use MM for months
mm are minutes
2 Likes
VBA does not have DateTime.TryParseExact method
hello @raghuramk
you can use DateValue function to check if your given date is in specific format or not
like in your case you can use
dVal = DateValue(Replace(ActiveCell.Value, “.”, “-”))
if it throws type mismatch error then cell value is not in correct format
more info