Pivot cache range/Source data.. Pls help me out.
Posted by Mr Peter Pettersson on August 28, 2001 12:37 AM
To all pros building makros:
I have a problem to make a pivot out of a selected range. As the range for the pivot cache variates from
time to time I'll run the makro. I want the source
data to be the range selected.
Can anyone find me a solution to this problem?
Code:
Worksheets("Blad1").Activate
Range("B1").Select
Selection.End(xlDown).Activate
ActiveCell.CurrentRegion.Select
(This command selects the range I want in my pivottable)
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
' "Blad1!R10C2:R20C8").CreatePivotTable TableDestination:=range("J1"), _
' TableName:="Pivottabell2"
'ActiveSheet.PivotTables("Pivottabell2").SmallGrid = False
..........
Thank U!