Adjust Chart for all WorkSheets VBA

Sherifa

New Member
Joined
Oct 23, 2017
Messages
45
I want to be able to copy and paste an Excel Chart using vba to set number of worksheets, but to adjust the range for the charts to that particular spreadsheet, this how far I've gotten but I have an error

Code:
Sub CopyCharts()
Dim Wkb As Excel.Workbook
Dim ws As Worksheet
Dim ws_count As Integer
Dim i As Integer




Sheet4.ChartObjects("ALLDeals").Copy


        Set Wkb = ThisWorkbook
        ws_count = Wkb.Worksheets.Count
                
                     
        'Begin loop
        For i = 4 To ws_count
        
        Set TargetSheet = Wkb.Worksheets(i)
                        
        TargetSheet.ChartObjects("ALLDeals").Paste
        
        
Sheet4.ChartObjects("ALLVolume").Copy
                           
         TargetSheet.TargetSheet.ChartObjects("ALLVolume").Paste


      Next
End Sub
 
Last edited:

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Works to copy and paste the chart, but it does not adjust the chart to the relevant spreadsheet data.
It does not position the charts in the range selected when it is pasted.

Code:
Sub CopyCharts()Dim Wkb As Excel.Workbook
Dim ws As Worksheet
Dim ws_count As Integer
Dim i As Integer








        Set Wkb = ThisWorkbook
        ws_count = Wkb.Worksheets.Count
                
                     
        'Begin loop
        For i = 4 To ws_count
        
[B]        Set TargetSheet = Wkb.Worksheets(i)[/B]
[B]        Sheet4.ChartObjects("ALLDeals").Copy[/B]
[B]        Range("q19").Select[/B]
[B]        TargetSheet.Paste[/B]


[B]        Sheet4.ChartObjects("ALLVolume").Copy[/B]
[B]        Range("aa19").Select[/B]
[B]        TargetSheet.Paste[/B]


      Next
      
End Sub
 
Upvote 0
Could you explain more in detail what you want to do?
 
Upvote 0
Each Excel sheet has table data in the same place, which the charts are based on.
I want the charts to change as they are pasted into a new worksheet
 
Upvote 0
Why would you need paste charts? Wouldn't it better to create a chart one time and adjust it to range?
 
Upvote 0
I have created two charts, but I want to adjust the range for 42 worksheets.
I'm less than a week old to Bloomberg, so didn't know the best way.
The range is the same for all the worksheets.
How can I go about this?
 
Upvote 0
If the range is the same for all worksheets, then there's a way to fill chart with actual values (rather binding it to sheet's range).
Could you post the sample workbook to some cloud storage (with sensitive data removed)?
 
Upvote 0
Is there any way you can guide me through, all data is sensitive, because this is a work document.
Or refer me to a source that explains?
I've searched online, but can't quite find what I'm looking for.
 
Upvote 0
Yes, it requires VBA. Here is the sample code which fills chart with values.
 
Upvote 0

Forum statistics

Threads
1,215,045
Messages
6,122,840
Members
449,096
Latest member
Erald

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