1
votes

I have two Sheets, and would like to copy the Chart from sheet1 to sheet2.

I am using the below code, the code is removing the Chart from Sheet1 and pasting them into sheet2. Instead, I would just like to have the duplicate of the Chart.

ALso, I would like to have my Charts in particular range. How can I edit them ?

Anylead would be helpful

 Sub overview1()
    Dim chartobj As Object
    For Each chartobj In Sheets("CAT").ChartObjects
    chartobj.chart.Location xlLocationAsObject, "Overview_1"

    Next chartobj
    For Each chartobj In Sheets("Dev").ChartObjects
    chartobj.chart.Location xlLocationAsObject, "Overview_1"
    Next chartobj
End sub
1

1 Answers

2
votes

You should try to make use of a copy/paste technique, like the below.

Sub overview1()
    Dim OutSht As Worksheet
    Dim Chart As ChartObject
    Dim PlaceInRange As Range

    Set OutSht = ActiveWorkbook.Sheets("Overview_1") '<~~ Output sheet
    Set PlaceInRange = OutSht.Range("B2:J21")        '<~~ Output location

    'Loop charts
    For Each Chart In Sheets("CAT").ChartObjects
        'Copy/paste charts
        Chart.Copy
        OutSht.Paste PlaceInRange
    Next Chart

End Sub

This is just a simple example which should keep you going. Obviously this example pastes all charts in the exact same locataion in the output sheet, which probably isn't what you are looking for.