How to Change the Date Format in VBA Code?

punnipah

Board Regular
Joined
Nov 3, 2021
Messages
134
Office Version
  1. 2019
Platform
  1. Windows
Hi,

i wan to Convert Format dd/mm/yyyy to yyyy/mm/dd




My Code Can't Working

Sub Date_Format_Example2()

Range("A1").NumberFormat = "yyyy/mm/dd"

End Sub

Data
1676273496371.png



Book1
A
112.02.2023
Sheet1
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Try...
VBA Code:
Sub Date_Format_Example2()

    With Range("A1")
        .Replace What:=".", Replacement:="/", LookAt:=xlPart
        .NumberFormat = "yyyy/mm/dd"
    End With

End Sub
 
Upvote 0
Solution
Try...
VBA Code:
Sub Date_Format_Example2()

    With Range("A1")
        .Replace What:=".", Replacement:="/", LookAt:=xlPart
        .NumberFormat = "yyyy/mm/dd"
    End With

End Sub
Thank you Very much
 
Upvote 0

Forum statistics

Threads
1,214,391
Messages
6,119,244
Members
448,879
Latest member
VanGirl

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