How to Validate date in the format yyyy.mm.dd using vba code

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

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

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:
@AkshaySandhu