Date Conversion Script

lightningmtv

New Member
Joined
Nov 1, 2022
Messages
3
Office Version
  1. 2021
Platform
  1. Windows
Hello Everyone
Im working on an excel sheet where all the dates are formatted the following: "1st Jan 2010" the only problem is that excel does not see this as a date.
Is it possible with a script to change this too a for excel readable date format?
Dates are in row I, J, K and L

Thanks in advance.
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Presumably you mean Columns I, J, K & L? No idea where your data starts - the following suggestion assumes it starts on row 2. Try it on a copy of your actual sheet.
In future, please look at XL2BB - Excel Range to BBCode to post a copy of your sheet (so we don't have to guess what it looks like ;))
VBA Code:
Option Explicit
Sub OrdToCard()
    Dim ws As Worksheet
    Set ws = Worksheets("Sheet1")   '<~~ *** Change to actual sheet name ***
    
    With ws.Range("I2:L" & ws.Range("I:L").Find("*", , xlFormulas, , xlByRows, xlPrevious).Row)
        .Value2 = Evaluate("TEXT(DATEVALUE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(" & .Address & ",""st "",""-""),""nd "",""-""),""rd "",""-""),""th "",""-"")),""d mmmm yyyy"")")
    End With
    
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,215,416
Messages
6,124,772
Members
449,187
Latest member
hermansoa

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