Macro- To use loops but for specific charts

SloppyJ

New Member
Joined
May 3, 2011
Messages
5
I got 30 different charts in a sheet and I want a macro to select 6 specific charts by name to be copied.

So I need a macro like,

For each charts in activesheet.shapes.range("Chart 1", "Chart 3", "Chart 10",.....)

'To be selected and copied

Any help will be greatly appreciated, thanks!
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
... 'To be selected and copied ...1

Hi
Welcome to the board


Remark: You don't usually select objects in vba.

This is an example that copies some charts from Sheet1 to Sheet2. The charts are pasted with the top left on the cells in row 5, every 10 columns.

Try and adapt for your case:

Code:
Sub CopyShapes()
Dim wsSrc As Worksheet, wsDest As Worksheet
Dim shpR As ShapeRange
Dim shp As Shape
Dim lCol As Long
 
Set wsSrc = Worksheets("Sheet1")
Set wsDest = Worksheets("Sheet2")
Set shpR = wsSrc.Shapes.Range(Array("Chart 1", "Chart 2", "Chart 5"))
 
lCol = 1
For Each shp In shpR
    shp.Copy
    wsDest.Paste wsDest.Cells(5, lCol)
    lCol = lCol + 10
Next shp
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,585
Messages
6,179,702
Members
452,938
Latest member
babeneker

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