user3421281
user3421281

Reputation: 1

Mismatch Error on Duplicate Method

I'm trying to implement some vba code in excel 2007 to copy a chart(chart object), then move it to another sheet. I'd worked a way to do this fine, but when encountered some issues in 2010. I've since turned to using the chartobject.duplicate method to create the copy, but am running into a mismatch error. The program does infact duplicate the chart but still gives an error.

Dim w As Double 'The width of the new table
Dim h As Double 'The height of the new table
Dim cht As ChartObject



    Worksheets("Charts").ChartObjects("OT DAY").Activate
    Set cht = Worksheets("Charts").ChartObjects("OT DAY").Duplicate
    cht.Name = "Chart 1"
    Worksheets("Charts").Charts("Chart 1").Location xlLocationAsNewSheet, curMod

The error occurs when I set cht to the objectchart duplicate.

Thanks!

Upvotes: 0

Views: 290

Answers (1)

Tim Williams
Tim Williams

Reputation: 166825

Dim cht As Shape 'not ChartObject

Upvotes: 1

Related Questions