Format Date With VBA (Remove TimeStamp)

PatrickW1907

New Member
Joined
Sep 3, 2022
Messages
18
Office Version
  1. 365
Platform
  1. Windows
Hi All

I Wondered if anyone could help.

I have the following Data in Column E which is a CSV export.

I've been trying to build a code which will tidy the data.

In short I want to do the following:

  • Remove Spaces from Column E
  • Remove Timestamp from Column E
  • All should be a UK date but I've noticed when playing with Macros it sometimes convert to US I need to keep it UK.
  • The number of rows in the data change so will need last row in there rather than a set range.
All that should remain in Column E is the UK date (no spaces and No Timestamp).


Appreciate the help guys.

Data below

The data aligned to the right is due to a space in the cell and it has the format 00:00:00 compared to those aligned to the left that has 00:00

Date Generated
06/01/2019 00:00​
28/06/2019 00:00
28/06/2019 00:00
28/06/2019 00:00
06/05/2019 00:00​
07/09/2019 00:00​
28/07/2019 00:00
28/06/2019 00:00
28/06/2019 00:00
23/07/2019 00:00
30/07/2019 00:00
28/06/2019 00:00
28/06/2019 00:00
28/06/2019 00:00
07/05/2019 00:00​
17/07/2019 00:00
28/06/2019 00:00
28/06/2019 00:00
07/10/2019 00:00​
28/07/2019 00:00
28/08/2019 00:00
 
Just be careful with the dates you have, it looks to me that the ones that have moved to the right have already had their month and day reversed.
The date range to me looks to be from 28 Jun to 28 Aug and they are falling outside of that range.

Ideally go back to the source data and run the process again. Perhaps import the dates as text first and then run Jimmy's code on that.
Thanks Alex much appreciated !!
 
Upvote 0

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).

Forum statistics

Threads
1,224,827
Messages
6,181,198
Members
453,022
Latest member
RobertV1609

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