is it Possable to access a hole Pivot table by name for a Pivot Chart?

Saperblue56

New Member
Joined
Aug 14, 2017
Messages
9
Hello once again All,
well the Title says it all

Here my code:
Code:
    Sheets("Anzahl_Kategorien_je_Kunde").Select
    Dim PvData As Range
    Dim PVLastRow As Longt
    PVLastRow = Range("A" & Rows.Count).End(xlUp).Row
    PvData = "'Anzahl_Kategorien_je_Kunde'!A1:H" & PVLastRow
    Cells(1, 1).Select
    ActiveWorkbook.ShowPivotTableFieldList = True
    ActiveSheet.Shapes.AddChart.Select
    ActiveChart.SetSourceData Source:=Range( _
        PvData)
    ActiveWorkbook.ShowPivotChartActiveFields = True
    ActiveChart.ChartType = xlColumnClustered
    With ActiveSheet.PivotTables("Kategorien_je_Kunde").PivotFields("Kunde")
        .Orientation = xlRowField
        .Position = 1
    End With
    With ActiveSheet.PivotTables("Kategorien_je_Kunde").PivotFields("SF")
        .Orientation = xlRowField
        .Position = 2
    End With
    ActiveSheet.PivotTables("Kategorien_je_Kunde1").AddDataField ActiveSheet.PivotTables( _
        "Kategorien_je_Kunde").PivotFields("Häufigkeit"), "Summe von Häufigkeit", xlSum
    With ActiveSheet.PivotTables("Kategorien_je_Kunde").PivotFields("Kategorie")
        .Orientation = xlPageField
        .Position = 1
    End With
    With ActiveSheet.PivotTables("Kategorien_je_Kunde").PivotFields("Erstellungs-Datum")
        .Orientation = xlPageField
        .Position = 2
    End With
    Range("B6").Select
    With ActiveSheet.PivotTables("Kategorien_je_Kunde").PivotFields("Team")
        .Orientation = xlPageField
        .Position = 3
    End With

It has Problems on the line :

vData = "'Anzahl_Kategorien_je_Kunde'!A1:H" & PVLastRow

also PVLastRow seams only to be =1 is this because the Pivot Table hasent been made yet ?
if Yes can someone help me to get round this.
All Help or Ideas Welcom

Ray
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

Forum statistics

Threads
1,224,827
Messages
6,181,194
Members
453,021
Latest member
pingpong7117

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
Back
Top