I keep on getting an Error over this part of my Macro and i cannot find out why. any help will be much appreciated. I am trying to AutoFill Column "A", however i need it to be as long as column "B".
Range("A1").SelectActiveCell.FormulaR1C1 = "C/R"
Range("A2").Select
ActiveCell.FormulaR1C1 = "=IF(RC[18]<=TODAY()-534,""R"",""C"")"
Range("A2").Select
With Sheets("Sheet2")
Dim LastRow As Long
LastRow = Range("B" & Rows.Count).End(xlUp).Row
With Range("A2")
.FormulaR1C1 = "=RC[-2]*(-1)+RC[-1]"
.AutoFill Destination:=Range("A2:A" & LastRow)
End With
End With
Range(Selection, Selection.SpecialCells(xlLastCell)).Select
Sheets("Sheet2").Select
Sheets("Sheet2").Name = "EUREKA"
Range("A1").Select
Sheets.Add
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"EUREKA!R1C1:R12C48", Version:=xlPivotTableVersion14).CreatePivotTable _
TableDestination:="Sheet4!R3C1", TableName:="PivotTable5", DefaultVersion _
:=xlPivotTableVersion14
Sheets("Sheet4").Select
Cells(3, 1).Select
With ActiveSheet.PivotTables("PivotTable5").PivotFields("C/R")
.Orientation = xlRowField
.Position = 1
End With
With ActiveSheet.PivotTables("PivotTable5").PivotFields("COMPANY")
.Orientation = xlRowField
.Position = 2
End With