Pivot Chart help needed

MartinL

Well-known Member
Joined
Oct 16, 2008
Messages
1,141
Office Version
  1. 365
Platform
  1. Windows
I am trying to create a chart on each sheet.
my method was to use pivot table/chart and then whan the sheet was copied the table/chart would get updated with the new data.
Not So

so I am now trying the same thing but on a button. I recorded a macro and am now trying to modify it by changing the hard coded bits to variables.

I am hitting a problem here - right at the top :eek:(

stepping through the code [F8] it fails at:
Code:
    WB.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
        "'" + WS + "'!R6C71:R" + LR + "C74").CreatePivotTable TableDestination:= _
        "'[" + WB + "]" + WS + "'!R111C11", TableName:= _
        WS + " Chart", DefaultVersion:=xlPivotTableVersion10

this is what i have so far (plus the rest of the macro)

Code:
Dim WS As Worksheet
    Dim WB As Workbook
    Dim LR As Long
    Dim CN As String
    
    ActiveSheet.Unprotect
    With Application
        .Calculation = xlCalculationManual
    End With

    Range("A1").Select
    With ActiveSheet
        LR = .Cells(Rows.Count, "BS").End(xlUp).Row
    End With
'
    'ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
        "'JS PREP WK (42)'!R6C71:R93C74").CreatePivotTable TableDestination:= _
        "'[Auto board 131009 (VERSION 7a).xls]JS PREP WK (42)'!R111C11", TableName:= _
        "PivotTable3", DefaultVersion:=xlPivotTableVersion10
    
    WB.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
        "'" + WS + "'!R6C71:R" + LR + "C74").CreatePivotTable TableDestination:= _
        "'[" + WB + "]" + WS + "'!R111C11", TableName:= _
        WS + " Chart", DefaultVersion:=xlPivotTableVersion10
    
    CN = WS + " Chart"

any ideas what im doing wrong...?

Martin
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Oh 14 views and no comments

maybe someone can suggest a different method of achieving what i need to do...
 
Upvote 0

Forum statistics

Threads
1,215,514
Messages
6,125,269
Members
449,219
Latest member
daynle

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