Error resulting from date formatting

mikec82

Board Regular
Joined
Jan 13, 2009
Messages
225
I have a workbook with three sheets - Data, VisitDate1, and VisitDate2.

VisitDate1 takes the date from "Data": =INDEX(Data!H3:R3,MATCH(TRUE,INDEX((Data!H3:R3<>0),0),0)).

The result looks like this:
Mon, Sep 10, 2018
8:30AM - 2:00PM

<tbody>
</tbody>

VisitDate2 should take that date and strip it down to 9/10/18: =REPLACE(LEFT(REPLACE(VisitDate1!A3,FIND(",",VisitDate1!A3,5)-2,2,""),FIND(",",VisitDate1!A3,5)+3),1,5,"")+0

This used to work when the raw data was formatted with a "th" after the day:
Mon, Sep 10th, 2018
8:30AM - 2:00PM

Can I revise either the formula in VisitDate1 or VisitDate2 so that the result is 9/10/18? It is currently resulting in an error.

<tbody>
</tbody>
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
I just ended up adding another sub, shown below and it works now. How would I add additional years to the statement, so that it would change not only "2018", but also 2019, 2020, 2021, and 2022?

Sub DateFormat()
'
' DateFormat Macro
'


'
Sheets("Data").Select
Columns("H:R").Select
Selection.Replace What:=", 2018", Replacement:="th, 2018", LookAt:=xlPart _
, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Range("A1").Select
Sheets("Report").Select
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,375
Messages
6,124,589
Members
449,174
Latest member
chandan4057

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