I immediately receive an error "Invalid procedure call or argument." and the following lines are highlighted :
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _ "ResUsage!R1C2:R1048576C2", Version:=6).CreatePivotTable TableDestination:= _ "days_count!R3C1", TableName:="PivotTable2", DefaultVersion:=6