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

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
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,215,343
Messages
6,124,400
Members
449,156
Latest member
LSchleppi

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