VB converting to US date format ?

Pauljj

Well-known Member
Joined
Mar 28, 2004
Messages
2,047
Morning all,

I am using this code but as a result it is treating the month as a day and the day as a month.

I need it to appear as UK date format ....any ideas please

Code:
Cells(1, 9) = Day(Range("H1")) & "/" & Month(Range("H1") - 1) & "/" & Year(Range("H1"))
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Hi, you could try:

Code:
Cells(1, 9) = cdate(Day(Range("H1")) & "/" & Month(Range("H1") - 1) & "/" & Year(Range("H1")))

Or probably a better option:

Code:
Cells(1, 9) = dateadd("m",-1,range("H1").Value)
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,688
Members
448,978
Latest member
rrauni

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