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

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
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,356
Messages
6,124,471
Members
449,163
Latest member
kshealy

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