Best way to convert date input to dd-mm-yy (vba)

kelly mort

Well-known Member
Joined
Apr 10, 2017
Messages
2,169
Office Version
  1. 2016
Platform
  1. Windows
I am accepting date input as dd-mm-yy.
A user might enter 6-7-20.

In this case, I want to convert the input to 06-07-20.
I can do this with a few case statements and or if statements.

But I am having the feeling there could be a cleaner and shorter way to do it.

Can someone point it out for me?

Thanks
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Presuming your data is in column A, use this code.

Code:
Range("A2:A" & Rowcounter).NumberFormat = "dd-mm-yyyy"
 
Upvote 0
Presuming your data is in column A, use this code.

Code:
Range("A2:A" & Rowcounter).NumberFormat = "dd-mm-yyyy"

Sorry for not being clear.

I am using an input box to accept this date.

I want to do the manipulation within memory.

Thanks
 
Upvote 0

Forum statistics

Threads
1,213,484
Messages
6,113,924
Members
448,533
Latest member
thietbibeboiwasaco

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top