I have a VBA macro which prepares files to be able to be used. The last day or so, the splitting of the date has not worked properly and am wondering what might be wrong.
So the date comes from the data supplier as dd/mm/yyy hh:mm 24/11/2022 12:25:00. The macro has some code which adds an additional column and splits it so I have date and time separately. Both yesterday and today, once the macro was run, I had all the same time showing in the new column, but it should be whatever time was originally in column A
Below is a sample of the first 5 columns. What the code did with this data was create the new column as column B, but every cell in that column showed 12:25 as the time. Any thoughts on what is wrong, as it has worked fine for ages?
Here is the code
So the date comes from the data supplier as dd/mm/yyy hh:mm 24/11/2022 12:25:00. The macro has some code which adds an additional column and splits it so I have date and time separately. Both yesterday and today, once the macro was run, I had all the same time showing in the new column, but it should be whatever time was originally in column A
Below is a sample of the first 5 columns. What the code did with this data was create the new column as column B, but every cell in that column showed 12:25 as the time. Any thoughts on what is wrong, as it has worked fine for ages?
Here is the code
VBA Code:
Sub Prepare_Files()
'
' Prepare_Files Macro
' This macro prepares files to run selection macros
'
'
Dim ws As Worksheet, lc As Long, lr As Long
Set ws = ActiveSheet
'range from A1 to last column header and last row
lc = ws.Cells(1, ws.Columns.Count).End(xlToLeft).Column
lr = ws.Cells.Find("*", after:=ws.Range("A1"), LookAt:=xlPart, _
SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
With Application
.ScreenUpdating = False
.DisplayStatusBar = False
.EnableEvents = False
End With
Columns("W:W").Select
Selection.Insert Shift:=xlToRight
Range("W2").Select
ActiveCell.FormulaR1C1 = _
"=IF(RC[-1]=""X"",""x"",IF(AND(RC[-3]=""X"",RC[-2]=""X""),""**"",""*""))"
Range("W2").Select
Application.Run "PERSONAL.XLSB!CopyFormulaDownToLastRowOfData"
Columns("B:B").Select
Selection.Insert Shift:=xlToRight
Range("B1").Select
ActiveCell.FormulaR1C1 = "Date"
Columns("B:B").Select
Selection.NumberFormat = "dd/mm/yyyy"
Columns("C:C").Select
Selection.Insert Shift:=xlToRight
Range("C1").Select
ActiveCell.FormulaR1C1 = "Time"
Columns("C:C").Select
Selection.NumberFormat = "hh:mm"
Range("B2").Select
ActiveCell.FormulaR1C1 = "=INT(A2)"
Range("B2").Select
ActiveCell.FormulaR1C1 = "=INT(RC[-1])"
Range("B2").Select
Application.Run "PERSONAL.XLSB!CopyFormulaDownToLastRowOfData"
Range("C2").Select
ActiveCell.FormulaR1C1 = "=(RC[-2]-RC[-1])"
Range("C2").Select
Application.Run "PERSONAL.XLSB!CopyFormulaDownToLastRowOfData"
Columns("BV:BV").Select
Selection.Insert Shift:=xlToRight
Range("BV1").Select
ActiveCell.FormulaR1C1 = "Forecast Rank"
Range("BV2").Select
ActiveCell.FormulaR1C1 = _
"=IF(RC[-1]="""","""",COUNTIFS(C[-73],RC[-73],C[-72],RC[-72],C[-1],""<""&RC[-1])+1)"
Range("BV2").Select
Application.Run "PERSONAL.XLSB!CopyFormulaDownToLastRowOfData"
Columns("A:A").Select
Selection.Delete Shift:=xlToLeft
With Application
.ScreenUpdating = True
.DisplayStatusBar = True
.EnableEvents = True
End With
End Sub
vdw-place-adapted-2022-11-24-2022-11-24.csv | |||||||
---|---|---|---|---|---|---|---|
A | B | C | D | E | |||
1 | RH_DateAndTime | RH_RaceName | RH_NumberOfRunners | VDW_Win | VDW_Place | ||
2 | 11/24/22 12:25 | Download The At The Races App Conditional Jockeys' Handicap Hurdle | 8 | 70 | 92 | ||
3 | 11/24/22 12:25 | Download The At The Races App Conditional Jockeys' Handicap Hurdle | 8 | 70 | 92 | ||
4 | 11/24/22 12:25 | Download The At The Races App Conditional Jockeys' Handicap Hurdle | 8 | 70 | 92 | ||
5 | 11/24/22 12:25 | Download The At The Races App Conditional Jockeys' Handicap Hurdle | 8 | 70 | 92 | ||
6 | 11/24/22 12:25 | Download The At The Races App Conditional Jockeys' Handicap Hurdle | 8 | 70 | 92 | ||
7 | 11/24/22 12:25 | Download The At The Races App Conditional Jockeys' Handicap Hurdle | 8 | 70 | 92 | ||
8 | 11/24/22 12:25 | Download The At The Races App Conditional Jockeys' Handicap Hurdle | 8 | 70 | 92 | ||
9 | 11/24/22 12:25 | Download The At The Races App Conditional Jockeys' Handicap Hurdle | 8 | 70 | 92 | ||
10 | 11/24/22 12:30 | Irish Stallion Farms EBF Beginners Chase | 9 | 73.17 | 92.68 | ||
11 | 11/24/22 12:30 | Irish Stallion Farms EBF Beginners Chase | 9 | 73.17 | 92.68 | ||
12 | 11/24/22 12:30 | Irish Stallion Farms EBF Beginners Chase | 9 | 73.17 | 92.68 | ||
13 | 11/24/22 12:30 | Irish Stallion Farms EBF Beginners Chase | 9 | 73.17 | 92.68 | ||
14 | 11/24/22 12:30 | Irish Stallion Farms EBF Beginners Chase | 9 | 73.17 | 92.68 | ||
15 | 11/24/22 12:30 | Irish Stallion Farms EBF Beginners Chase | 9 | 73.17 | 92.68 | ||
16 | 11/24/22 12:30 | Irish Stallion Farms EBF Beginners Chase | 9 | 73.17 | 92.68 | ||
17 | 11/24/22 12:30 | Irish Stallion Farms EBF Beginners Chase | 9 | 73.17 | 92.68 | ||
18 | 11/24/22 12:30 | Irish Stallion Farms EBF Beginners Chase | 9 | 73.17 | 92.68 | ||
19 | 11/24/22 12:40 | Join Racing TV Now 'National Hunt' Novices' Hurdle (GBB Race) (Div 1) | 11 | 80.85 | 100 | ||
20 | 11/24/22 12:40 | Join Racing TV Now 'National Hunt' Novices' Hurdle (GBB Race) (Div 1) | 11 | 80.85 | 100 | ||
21 | 11/24/22 12:40 | Join Racing TV Now 'National Hunt' Novices' Hurdle (GBB Race) (Div 1) | 11 | 80.85 | 100 | ||
22 | 11/24/22 12:40 | Join Racing TV Now 'National Hunt' Novices' Hurdle (GBB Race) (Div 1) | 11 | 80.85 | 100 | ||
23 | 11/24/22 12:40 | Join Racing TV Now 'National Hunt' Novices' Hurdle (GBB Race) (Div 1) | 11 | 80.85 | 100 | ||
24 | 11/24/22 12:40 | Join Racing TV Now 'National Hunt' Novices' Hurdle (GBB Race) (Div 1) | 11 | 80.85 | 100 | ||
25 | 11/24/22 12:40 | Join Racing TV Now 'National Hunt' Novices' Hurdle (GBB Race) (Div 1) | 11 | 80.85 | 100 | ||
26 | 11/24/22 12:40 | Join Racing TV Now 'National Hunt' Novices' Hurdle (GBB Race) (Div 1) | 11 | 80.85 | 100 | ||
27 | 11/24/22 12:40 | Join Racing TV Now 'National Hunt' Novices' Hurdle (GBB Race) (Div 1) | 11 | 80.85 | 100 | ||
28 | 11/24/22 12:40 | Join Racing TV Now 'National Hunt' Novices' Hurdle (GBB Race) (Div 1) | 11 | 80.85 | 100 | ||
29 | 11/24/22 12:40 | Join Racing TV Now 'National Hunt' Novices' Hurdle (GBB Race) (Div 1) | 11 | 80.85 | 100 | ||
30 | 11/24/22 12:40 | Join Racing TV Now 'National Hunt' Novices' Hurdle (GBB Race) (Div 1) | 11 | 80.85 | 100 | ||
31 | 11/24/22 12:48 | Racing TV Black Friday Is Coming Novices' Hurdle (GBB Race) | 9 | 80.85 | 100 | ||
32 | 11/24/22 12:48 | Racing TV Black Friday Is Coming Novices' Hurdle (GBB Race) | 9 | 80.85 | 100 | ||
33 | 11/24/22 12:48 | Racing TV Black Friday Is Coming Novices' Hurdle (GBB Race) | 9 | 80.85 | 100 | ||
34 | 11/24/22 12:48 | Racing TV Black Friday Is Coming Novices' Hurdle (GBB Race) | 9 | 80.85 | 100 | ||
35 | 11/24/22 12:48 | Racing TV Black Friday Is Coming Novices' Hurdle (GBB Race) | 9 | 80.85 | 100 | ||
36 | 11/24/22 12:48 | Racing TV Black Friday Is Coming Novices' Hurdle (GBB Race) | 9 | 80.85 | 100 | ||
37 | 11/24/22 12:48 | Racing TV Black Friday Is Coming Novices' Hurdle (GBB Race) | 9 | 80.85 | 100 | ||
38 | 11/24/22 12:48 | Racing TV Black Friday Is Coming Novices' Hurdle (GBB Race) | 9 | 80.85 | 100 | ||
39 | 11/24/22 12:48 | Racing TV Black Friday Is Coming Novices' Hurdle (GBB Race) | 9 | 80.85 | 100 | ||
40 | 11/24/22 12:48 | Racing TV Black Friday Is Coming Novices' Hurdle (GBB Race) | 9 | 80.85 | 100 | ||
vdw-place-adapted-2022-11-24-20 |