Apply different charts across multiple Excel sheets (according to line numbers on each sheet)

I created a PivotChart showing major cities as "filter" (80 in total) and some performance metrics as "sum of values". In the Excel file, I have 26 sheets corresponding to the countries of these cities, and on each sheet a table with a list of cities (for some countries it may be 1 line (1 city), 5 lines or something else ..)

In each country sheet, I have to show this table (already done) along with a graph for each row of the table's performance (again, it could be 1, 5, or whatever).

I thought the easiest way to accomplish this is to insert a pivot chart in each sheet and then automatically select each row with the city name and apply it to the hinge filter.

So far, this is the code I wrote:

Sub PastPivot() 
    Dim sht As Worksheet
        ActiveSheet.ChartObjects("Chart 1").Activate
        ActiveChart.ChartArea.Copy
    For Each sht In Worksheets
        sht.Range("a16").PasteSpecial
    Next
    Application.CutCopyMode = False
End Sub

      

but I have a few questions:

  • It runs "error 5" when running the code

  • I'm not sure how to write the code to execute as many charts as there are rows on each sheet (and how to determine the position of the chart, given that I won't have the same number of charts on each sheet).

Perhaps the solution is to use a different type of graph rather than pivot.

Any advice on how to accomplish it?

+3
vba excel-vba excel


source to share


No one has answered this question yet

Check out similar questions:

3
Copy only selected table columns after filter to new sheet
1
How to add a dropdown list of strings that represent the names of different tables in Excel 2007?
1
Get row number from every cell in selected range in table with VBA?
0
How to use Excel VBA to: create a pivot table for different sheets, expand pivot to new workbooks, and save with a specific name
0
Troubleshoot an error when adding rows to multiple sheets
0
Excel VBA insert rows and copy data to multiple sheets
0
copy data from only 3 sheets and paste it into a new sheet - Excel
0
How do I use VBA to add an ID number to the end of each line?
-2
Hide rows based on cell value across 7 Excel VBA sheets



All Articles
Loading...
X
Show
Funny
Dev
Pics