I am working on a macro that designed to reformat data and it is coming along pretty well, but I keep getting the following error
Run-time error '1004':
Application-defined or object-defined error
Here is the code
Sub BeginReformat()
'Piecing together a macro
ActiveWorkbook.Sheets(1).Sort.SortFields.Clear
ActiveWorkbook.Sheets(1).Sort.SortFields.Add Key:=Range("R:R" _
), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Sheets(1).Sort
.SetRange Range("A:V")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
Range("C:C,E:E,F:F").Select
Range("F1").Activate
Selection.Insert Shift:=xlToRight
Range("C2").Select
Range("C2").FormulaR1C1 = "=(RC[20]&""-""&RC[-2]&""-""&RC[1])"
LastRow = ActiveSheet.UsedRange.Rows.Count
Range("C2").AutoFill Destination:=Range("C2:C" & LastRow)
Range("F2").Select
Range("F2").FormulaR1C1 = "=IF(Sheet1!$A$1 RC[-1]>=1,""Yes"",""No"")"
LastRow = ActiveSheet.UsedRange.Rows.Count
Range("F2").AutoFill Destination:=Range("F2:F" & LastRow)
End With
End Sub
The offending line is
Range("F2").FormulaR1C1 = "=IF(Sheet1!$A$1 RC[-1]>=1,""Yes"",""No"")"
I am sure that I calling this wrong but I am unsure as to how I should be calling it
Bookmarks