Pivot Table Help

fpskidmark

Board Regular
Joined
Sep 11, 2009
Messages
139
Dear Excel Experts,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>
<o:p> </o:p>
I am so desperately trying to run a recorded macro to create a pivot table from the data listed on sheet (“All”) onto Sheet (“Pivot Table”), but I’m having a very difficult time doing so (pls. see below). I understand recorded macros usually do not work on pivot tables, because every time a pivot table is created it generates a NEW table name, ex. pivottable1, pivottable2, etc…<o:p></o:p>
How can I overcome this problem? What code do I need to add to my macro to fix this problem?<o:p></o:p>
<o:p> </o:p>
Any suggestions would be greatly appreciated.<o:p></o:p>
<o:p> </o:p>
Sub Macro1()<o:p></o:p>
'<o:p></o:p>
' Macro2 Macro<o:p></o:p>
' Macro recorded 12/11/2009 by Felix<o:p></o:p>
'<o:p></o:p>
<o:p> </o:p>
'<o:p></o:p>
Sheets("Pivot table").Cells.Clear<o:p></o:p>
Sheets("All").Select<o:p></o:p>
Cells.Select<o:p></o:p>
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _<o:p></o:p>
"All!C1:C10").CreatePivotTable TableDestination:= _<o:p></o:p>
"'[Pivot Table.xls]Pivot Table'!C1:C10", _<o:p></o:p>
DefaultVersion:=xlPivotTableVersion10<o:p></o:p>
ActiveWorkbook.ShowPivotTableFieldList = True<o:p></o:p>
With Sheets("Pivot table").PivotTables(1).PivotFields("Account ID ")<o:p></o:p>
.Orientation = xlRowField<o:p></o:p>
.Position = 1<o:p></o:p>
End With<o:p></o:p>
With Sheets("Pivot table").PivotTables(1).PivotFields("LOB")<o:p></o:p>
.Orientation = xlRowField<o:p></o:p>
.Position = 2<o:p></o:p>
End With<o:p></o:p>
<o:p> </o:p>
Thank you.
 

Some videos you may like

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

Watch MrExcel Video

Forum statistics

Threads
1,122,511
Messages
5,596,581
Members
414,079
Latest member
Frills

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top