Macro to remove time and convert date less than 10 to mm/dd/yyyy

howard

Well-known Member
Joined
Jun 26, 2006
Messages
6,603
Office Version
  1. 2021
Platform
  1. Windows
I have dates in Col L in format dd/mm/yyyy

I have tries to write code to remove the time and where the first two numbers in the date for eg 09 is less than 10, to convert those date to mm/dd/yyy for eg 09/05/2017 must change to 05/09/2017 , 14/08/2017 must remain as is etc

Code:
 Sub Convert_Dates()
With Sheets("Imported Data")
        With .Range("L2:L" & .Cells(Rows.Count, "L").End(xlUp).Row)
                .TextToColumns Destination:=.Cells(1), _
                DataType:=1, TextQualifier:=1, _
                ConsecutiveDelimiter:=False, Tab:=True, _
                Semicolon:=False, Comma:=False, _
                Space:=False, Other:=False, FieldInfo:=Array(1, 4), _
                TrailingMinusNumbers:=True
        End With
    End With
    
End Sub



it would be appreciated if someone could kindly amend my code



Book1
L
1Date Processed
214/08/2017 00:00:00
318/08/2017 00:00:00
430/08/2017 00:00:00
530/08/2017 00:00:00
609/05/2017 00:00
7
8
9
10
11
Imported Data
 
Last edited:

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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