Rocky
Rocky

Reputation: 19

Date formatting in VBA

I have a date: SAT 29 JUN 19. How do I convert it into date format e.g. 29 JUN 19 using Excel-VBA. Thanks.

By using this code:
wb.ActiveSheet.Cells(erow, 1) = CDate(Format(RemoveWkDay, "DD MMM YY"))
The output is: 29/06/2019

Upvotes: 0

Views: 236

Answers (1)

AAA
AAA

Reputation: 3670

Based on your comments above, you can use:
wb.ActiveSheet.Range("A1:A30").NumberFormat = "dd mmm yy;@"
To do that for the whole column, use Range("A:A") instead.

In fact, you do not need VBA for this. You can just set that string as the custom format in the Sheet.

Upvotes: 1

Related Questions