PivotTable Macro not working

T

T De Villiers

This code doesnt work, SourceData:=.........
This section is the problem, many thks


Sub test()

x = Range("A50000").End(xlUp).Row
y = Range("IV1").End(xlToLeft).Column


Range("A1").Select
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:
_
"Original!" & Cells(x, 1).Address & "," & Cells(1
y).Address).CreatePivotTable TableDestination:="", TableName:= _
"PivotTable1", DefaultVersion:=xlPivotTableVersion10
ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3
1)
ActiveSheet.Cells(3, 1).Select
ActiveSheet.PivotTables("PivotTable1").AddFields RowFields:="Cat4"
_
ColumnFields:="Account"

ActiveSheet.PivotTables("PivotTable1").PivotFields("Amount").Orientatio
= _
xlDataField
ActiveWorkbook.ShowPivotTableFieldList = True
ActiveSheet.Name = "Check"
End Su
 
T

Tom Ogilvy

shouldn't this be

"Original!" & Cells(x, 1).Address & ":" & Cells(1,
y).Address

with a colon instead of a comma?

and your going from the last row in column A to the first row in column Y -
Legal - just making sure that is what you want.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top