Home > front end >  Copy a graph in Excel with VBA to a different sheet
Copy a graph in Excel with VBA to a different sheet

Time:11-18

I want to use a button to copy a graph from a different sheet, on to "Sheet 1" and into cell "G4".

So far i have tried the code below, but there always is an error when "pasting" into the desired destination.

What could you recommend? Any help is greatly appriciated.

Sub OBJC()

Worksheets("Tabelle 2").Charts(1).Copy

Worksheets("Tabelle 1").Paste Destination:=Worksheets("Tabelle 1").Range("G4")

End Sub

CodePudding user response:

Not sure why, but it worked for me when I activated the chart first.

    Sub OBJC()    
    Worksheets("Tabelle 2").ChartObjects(1).Activate
    ActiveChart.ChartArea.Copy
    Worksheets("Tabelle 1").Paste Destination:=Worksheets("Tabelle 1").Range("G4")
    End Sub
  • Related