Hi forum,
I am running macro to create PVIOT table where row can be different on each day. and once i'm running below posted code i'm getting an error "Invalid procedue or call an argument" :
Could you please advise?
lastrow = ActiveWorkbook.Worksheets("sheet1").Cells(Rows.Count, 1).End(xlUp).Row
' WBPivot.Names.Add Name:="Database", RefersTo:="=Sheet1!$A$1:$H$" & lastrow 'add a named range set to data range
ActiveWorkbook.Sheets.Add.Name = "Pivot Table"
Sheets("Pivot Table").Select
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
"Sheet1!$A$1:$H$" & lastrow).CreatePivotTable TableDestination:= _
"'Pivot Table'!R3C1", TableName:="PivotTable1", _
DefaultVersion:=xlPivotTableVersion10
Regards,
Simpson1
Bookmarks