Could you please help, what is wrong with my code below, i try to use dynamic range and create a new worksheet (any) for pivot table doesn't matter it's sheet 2,3,4...in this workbook
thanks in advance
thanks in advance
VBA Code:
Sub SURVEY()
Dim LR As Long, LC As Long, myrange As Range, myws As Worksheet
LR = Sheet1.Cells(Rows.Count, 1).End(xlUp).Row
LC = Sheet1.Cells(1, Columns.Count).End(xlToLeft).Column
Set myrange = Sheet1.Cells(1, 1).Resize(LR, LC)
Set myws = Worksheets.Add
'BELOW PART HAS ERROR 1004
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
myrange, Version:=6).CreatePivotTable TableDestination:= _
myws.Cells(1, 1), TableName:="PivotTable1", DefaultVersion:=6
Sheets(myws).Select
Cells(1, 1).Select
With ActiveSheet.PivotTables("PivotTable1")...............................................
Last edited by a moderator: