Hi guys,
I'm sent a file every month which have dates in US and European formats e.g. 08/01/2024 for the 1st Aug, and then 13/08/2024 for the 13th August. I have recorded a macro where I press text to column, then change the date to "MDY" which changes the dates into European format, which is correct.
When I run the macro, it doesn't work. I've tried finding different code or a different solution online to no avail. I tried to "find and replace" any "08/01" to "01/08" but again, this didn't work as code. I tried making a few tweaks to the code as well, but not found a solution yet.
Below is the code for the recorded for the Text To Column recorded macro:
Any ideas on how to fix this so I can run it as a macro would be appreciated - currently tearing my hair out!
I'm sent a file every month which have dates in US and European formats e.g. 08/01/2024 for the 1st Aug, and then 13/08/2024 for the 13th August. I have recorded a macro where I press text to column, then change the date to "MDY" which changes the dates into European format, which is correct.
When I run the macro, it doesn't work. I've tried finding different code or a different solution online to no avail. I tried to "find and replace" any "08/01" to "01/08" but again, this didn't work as code. I tried making a few tweaks to the code as well, but not found a solution yet.
Below is the code for the recorded for the Text To Column recorded macro:
VBA Code:
Sheets("Sheet1").Select
Columns("A:A").Select
Selection.TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, _
Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
:=Array(1, 3), TrailingMinusNumbers:=True
Range("C4").Select
Here's the "Find Replace" macro:
Sheets("Sheet1").Select
Columns("A:A").EntireColumn.Select
Selection.Replace What:="08/01", Replacement:="01/08/2024", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False, FormulaVersion:=xlReplaceFormula2
Selection.Replace What:="08/02", Replacement:="02/08", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False, FormulaVersion:=xlReplaceFormula2
Selection.Replace What:="08/03", Replacement:="03/08", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False, FormulaVersion:=xlReplaceFormula2
Selection.Replace What:="08/04", Replacement:="04/08", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False, FormulaVersion:=xlReplaceFormula2
Selection.Replace What:="08/05", Replacement:="05/08", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False, FormulaVersion:=xlReplaceFormula2
Selection.Replace What:="08/06", Replacement:="06/08", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False, FormulaVersion:=xlReplaceFormula2
Selection.Replace What:="08/07", Replacement:="07/08", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False, FormulaVersion:=xlReplaceFormula2
Selection.Replace What:="08/09", Replacement:="09/08", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False, FormulaVersion:=xlReplaceFormula2
Selection.Replace What:="08/10", Replacement:="10/08", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False, FormulaVersion:=xlReplaceFormula2
Selection.Replace What:="08/11", Replacement:="11/08", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False, FormulaVersion:=xlReplaceFormula2
Selection.Replace What:="08/12", Replacement:="12/08", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False, FormulaVersion:=xlReplaceFormula2
Any ideas on how to fix this so I can run it as a macro would be appreciated - currently tearing my hair out!
Last edited by a moderator: