How to Validate date in the format using vba code

I need to validate for a cell in excel using vba code

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


Thank you for that… @tdhaene
i typed from my mobile…thats why… :stuck_out_tongue_winking_eye:

1 Like

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

So This one is from uipath activiy

Cheers @AkshaySandhu @raghuramk

Isnt that from Vb.Net…?
and OP requested for VBA

yes buddy, i suggested with uipath studio :slightly_smiling_face: