VBA Code Help

markster

Well-known Member
Joined
May 23, 2002
Messages
579
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Hey folks

I'm after a bit of macro code that will solve a problem. I have a spreadsheet with thousands of transactions. The date and time of the transaction is in Column B (B7 to B65000). The date and time format is as follows 2020.11.24 02:52:51. I'm only interested in the date of the transaction and not the time. I'm after some macro code that will look down column B and change the date format to DD-MMM-YY and remove the time of the transaction. So in the example I've given it will just be changed to 24-NOV-20. Can Anyone help?

Thanks in advance
Mark
 

Attachments

  • 1606235433696.png
    1606235433696.png
    1.1 KB · Views: 5
On my XL2010 (on a Windows 10 computer), your code worked whether the values were text or real dates formatted to look like the OP posted.
Yeah, it is just that if they were already dates, some of my functions would be overkill and unnecessary (and things could be simplified a little bit).
 
Upvote 0

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Here is another macro that will work with either text or real dates...
VBA Code:
Sub MyDateConvertMacro()

  With Range("B7", Cells(Rows.Count, "B").End(xlUp))
    .Replace " *", "", xlPart, , , , False, False
    .Replace ".", "/"
    .NumberFormat = "dd-mmm-yy"
  End With
   
End Sub
 
Upvote 0
Thanks everyone much appreciated. Will try the solutions now. Cheers
 
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,717
Members
448,985
Latest member
chocbudda

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