Hi,
I have a simple Excel-sheet with some data from an SQL-export. Row B contains information on your typical age-intervals (0 - 9, 10 - 19, 20 - 29, 30 - 39....). The intervals are formatted as text. Unfortunately, Excel automatically converts the interval "10 - 19" to a date, Oct-19.
0 - 9
Oct-19
20 - 29
30 - 39
40 - 49
50 - 59
60 - 69
70- 79
80 - 89
When I examine these cells I notice that the original information is lost - formatting the cells back to "General" results in a date number = 43739.
I want to find and replace all instances of "Oct-19" in column B, with "'10 - 19" using VBA. This works perfectly well when done manually. I have recorded the steps, but for some reason, this does nothing when executed as code:
I have tried replacing What:="01-10-2019" with "Oct-19". Also tried adding a format, What:=Format("01-10-2019", "dd/mm/yyyy"). Still nothing. I'm missing something here?
I have a simple Excel-sheet with some data from an SQL-export. Row B contains information on your typical age-intervals (0 - 9, 10 - 19, 20 - 29, 30 - 39....). The intervals are formatted as text. Unfortunately, Excel automatically converts the interval "10 - 19" to a date, Oct-19.
0 - 9
Oct-19
20 - 29
30 - 39
40 - 49
50 - 59
60 - 69
70- 79
80 - 89
When I examine these cells I notice that the original information is lost - formatting the cells back to "General" results in a date number = 43739.
I want to find and replace all instances of "Oct-19" in column B, with "'10 - 19" using VBA. This works perfectly well when done manually. I have recorded the steps, but for some reason, this does nothing when executed as code:
Code:
Columns("B:B").Select Selection.Replace What:="01-10-2019", Replacement:="'10 - 19", LookAt:= _
xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
I have tried replacing What:="01-10-2019" with "Oct-19". Also tried adding a format, What:=Format("01-10-2019", "dd/mm/yyyy"). Still nothing. I'm missing something here?