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

kelly mort

Well-known Member
Joined
Apr 10, 2017
Messages
2,096
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

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

ChrisFoster

Board Regular
Joined
Jun 21, 2019
Messages
160
Office Version
  1. 365
Platform
  1. Windows
Presuming your data is in column A, use this code.

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

kelly mort

Well-known Member
Joined
Apr 10, 2017
Messages
2,096
Office Version
  1. 2016
Platform
  1. Windows
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
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,893
Messages
5,834,274
Members
430,273
Latest member
Windrunner

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
Top