Hi
I tried to amend the following macro however before I can proceed any further its giving me an error
The first line of formula works ok
The second and third lines of formula is where the problem lies
will appreciate all help in order to fix my macro wherever possible
Thank you in anticipatioe
I tried to amend the following macro however before I can proceed any further its giving me an error
The first line of formula works ok
The second and third lines of formula is where the problem lies
will appreciate all help in order to fix my macro wherever possible
Thank you in anticipatioe
Code:
Sub MacroTest()
'Sheets("Analysis").UsedRange.Offset(1).Clear'
Application.DisplayAlerts = False
On Error Resume Next
Worksheets("RaceData").Delete
On Error GoTo 0
Application.DisplayAlerts = True
Worksheets("Racescrape").Copy Before:=Worksheets(1)
With Worksheets(1)
.Name = "Racedata"
LR = .Cells(Rows.Count, 1).End(xlUp).Row
Columns("K:K").EntireColumn.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Columns("o:o").EntireColumn.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Columns("K:K").EntireColumn.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
On Error Resume Next
SR = .Columns(1).Find("Tab", LookIn:=xlValues, Lookat:=xlPart).Row
On Error GoTo 0
If IsError(Z) Then GoTo Quit:
FindLoop:
LR = .Cells(Rows.Count, 1).End(xlUp).Row
If SR > LR Then GoTo Quit
On Error Resume Next
ER = 0
ER = .Range("A" & SR + 1 & ":A" & LR).Find("Tab", LookIn:=xlValues, Lookat:=xlPart).Row
On Error GoTo 0
If ER = 0 Then GoTo Quit
V = ER - SR
If V <> 27 Then
If V < 27 Then
.Rows(ER - 5 & ":" & ER + 21 - V).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Else
.Rows(SR + 23 & ":" & ER - 5).EntireRow.Delete
End If
End If
Range("K" & SR + 1 & ":K" & SR + 22).FormulaR1C1 = "=IF(RC[-1]="""","""",(RC[-2]+RC[-1])/2)"
Range("K" & SR + 1 & ":K" & SR + 22).Value = Range("K" & SR + 1 & ":K" & SR + 22).Value
Range("0" & SR + 1 & ":0" & SR + 22).FormulaR1C1 = "=SUM(--MID(SUBSTITUTE("-"&N6,"-",REPT(" ",15)),{15;30},15))/2)"
Range("0" & SR + 1 & ":0" & SR + 22).Value = Range("0" & SR + 1 & ":0" & SR + 22).Value
Range("q" & SR + 1 & ":q" & SR + 22).FormulaR1C1 = "=SUM(--MID(SUBSTITUTE("-"&p6,"-",REPT(" ",15)),{15;30},15))/2)"
Range("q" & SR + 1 & ":q" & SR + 22).Value = Range("q" & SR + 1 & ":q" & SR + 22).Value
SR = SR + 27
GoTo FindLoop
Quit:
.Range("A:br").EntireColumn.AutoFit
End With
End Sub