TheRedCardinal
Board Regular
- Joined
- Jul 11, 2019
- Messages
- 243
- Office Version
- 365
- 2021
- Platform
- Windows
My workbook has some imported data in it, currently manually pasted.
One of the columns is a date field, but the source data can vary in format and either be what should be DD.MM.YYYY or DD/MM/YYYY depending on the source spreadsheet.
As I need to work with the dates, I wrote a macro to replace the "." with "/" and then format as short date.
The incoming data should be in "General Format"
I wrote this:
I think the first line is now redundant.
If the data has "/" separators then everything works ok.
But if it is "." then the program switches it from dd.mm to mm/dd for no reason that I fathom.
Any tips?
One of the columns is a date field, but the source data can vary in format and either be what should be DD.MM.YYYY or DD/MM/YYYY depending on the source spreadsheet.
As I need to work with the dates, I wrote a macro to replace the "." with "/" and then format as short date.
The incoming data should be in "General Format"
I wrote this:
VBA Code:
.Columns("B").NumberFormat = "General"
.Columns("B").Replace ".", "/", xlPart, xlByRows, True
.Columns("B").NumberFormat = "dd/mm/yyyy"
I think the first line is now redundant.
If the data has "/" separators then everything works ok.
But if it is "." then the program switches it from dd.mm to mm/dd for no reason that I fathom.
Any tips?