MrExcel Publishing
Your One Stop for Excel Tips & Solutions

vb code to delete chart

Posted by Click on February 15, 2001 6:05 AM

i have a macro to create a simple graph on a worksheet but because it's only a temporary chart i want it to be deleted shortly after it is created and has outlived it's usefulness, it says the delete method fails, same for cut, could anyone suggest a good code to resolve this? please help, preferably by e-mail but reply to this message if you want, thanks very much.

Posted by Dave Hawley on February 15, 2001 7:04 AM

Hi Click

This should work, just change sheet code name to suit.

Sub TryThis()
End Sub

OzGrid Business Applications

Posted by Click on February 17, 2001 3:39 AM

further question (do people read this far down the page?)

i tried that before but got a 1004 error or something saying that method failed, even though it was legal and all (one of ecel's notions) in the end i managed to scrape together this piece of code which works:


the problem was to display a chart in a userform, so in the end i created a macro that created the graph on a sheet, then exported it to a folder, then deleted it off the sheet. a picture object on the form then set that file as the image source, and the image was then deleted from the folder, so it works and only takes about a half a second to execute, has anyone any other suggestions as to how to accomplish this?