changing date format

bobkasterop

New Member
Joined
May 10, 2018
Messages
6
Hey, so i have to change the date format in an excel sheet from yy-mm-dd to dd-mm-yy.
i tried using numberformat like this 'Range("A2", "A50000").NumberFormat = "dd-mm-yy"' but this doesnt change anything.
i also tried using format(Date,"dd-mm-yy") but this just sets the cell to have the date of today (from my computer)
i think that the reason for numberformat not working is that Excel doesnt really know which of the bits is yy which is dd and which is mm and therefore is thinking that they are allready in the right order.

my question is therefore:
how do i make excel now that right now it is in the order of yy-mm-dd? so that i aftwerwards can use numberformat.
 
This just inserts a new row in D and inserts "=RIGHT(A2,2)&""-""& Mid(A2, 4, 2) & ""-""&LEFT(A2,2)" into all the cells in that row...
I assume you mean inserts a new column in B. Seems you have a stubborn case of cells formatted as text. Here's another shot at beating that problem, and if it doesn't work I'm out of cards to play.
Code:
Sub ChangeDateFormat()
'Assumes initial format is yy-mm-dd and changes it to dd-mm-yy
Application.ScreenUpdating = False
Columns("B").Insert
With Range("B2:B50000")
    .Formula = "=RIGHT(A2,2)&""-""& Mid(A2, 4, 2) & ""-""&LEFT(A2,2)"
    .TextToColumns
    .Value = .Value
End With
Columns("A").Delete
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

Forum statistics

Threads
1,222,830
Messages
6,168,509
Members
452,194
Latest member
Lowie27

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