0

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

4
  • What's the value of RemoveWkDay? And isn't the output what you wanted - A date? Commented Jun 29, 2019 at 17:35
  • In this example the value of RemoveWkDay is 29 JUN 19 which is in general format.I want to convert it into date but preserve the same format DD MM YY.The cell A1 to A30 contains date for the month of June 2019 in an random order.My program will sort it out in an asecending order. Commented Jun 29, 2019 at 17:47
  • You mean DD MMM YY. Check answer below Commented Jun 29, 2019 at 18:05
  • Exchange CDate and Format: Start with CDate first and then do the Format. Commented Jun 29, 2019 at 23:53

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

@Asger, Yes, I did. Thank you. I have amended answer. OP hasn't bothered to say if it solved the problem..lol

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.