Change date format "yyyy/mm/dd" to dd/mm/yyyy

baskar5353

Board Regular
Joined
Mar 21, 2015
Messages
114
hi,

i having one workbook in this few columns contains the "yyyy/mm/dd" format. how to convert this format to dd/mm/yyyy

i want to remove this " symbol and convert to dd/mm/yyyy

how to do in VBA

Regards,
Baskar
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
If it literally does have the quotes around the date try...
Code:
Sub Macro2()
    With Columns("A")
        .Replace What:="/", Replacement:="-", LookAt:=xlPart
        .Replace What:="""", Replacement:="", LookAt:=xlPart
        .NumberFormat = "dd/mm/yyyy"
    End With
End Sub

Change the column to suit
 
Last edited:
Upvote 0
Thanks to Joe4 example, I think this might work for ya. You didn't give us a specific location where the dates are located so I'm putting column B for an example.


Code:
Sub FormatDate()


    Dim myFirstCol As String
    Dim myAllCols As Variant
    Dim myLastRow As Long
    Dim i As Long
    Dim myCol As String
    Dim myCell As Range

    Application.ScreenUpdating = False
    
'   Specify columns to apply to
    myAllCols = Array("B")

'   Find last row with data
    myLastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
       
'   Loop through all columns
    For i = LBound(myAllCols) To UBound(myAllCols)
        myCol = myAllCols(i)
'   Format column as text
        Columns(myCol).NumberFormat = "@"
'   Loop through cells in column, converting the ones that have values to text in "dd/mm/yyyy" format
        For Each myCell In Range(Cells(1, myCol), Cells(myLastRow, myCol))
            If Len(myCell) > 0 Then myCell = Format(myCell, "dd/mm/yyyy")
        Next myCell
    Next i
    
    Application.ScreenUpdating = True




End Sub
 
Upvote 0
but some cell it contains in this format 2010-15-06 1.02.30 i want only 2010-15-06 can we trim how can to do it
 
Upvote 0

Forum statistics

Threads
1,214,919
Messages
6,122,259
Members
449,075
Latest member
staticfluids

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