Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
how to delete a chart using code?
How do I delete a chart for which I do not have a name but only the cell the chart is anchored in using code? I.e. when I created the chart I pasted in in a cell. Now I want to be able to delete it by somehow referring to the cell I pasted it into. -- pwermuth ------------------------------------------------------------------------ pwermuth's Profile: http://www.excelforum.com/member.php...o&userid=24997 View this thread: http://www.excelforum.com/showthread...hreadid=386319 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
how to delete a chart using code?
if you have multiple charts:
Dim chartobj as ChartObject for each chartobj in ActiveSheet.ChartObjects if chartObj.TopLeftCell.Address = "$B$9" then chartObj.Delete end if Next If only one activesheet.ChartObjects(1).Delete -- Regards, Tom Ogilvy "pwermuth" wrote in message ... How do I delete a chart for which I do not have a name but only the cell the chart is anchored in using code? I.e. when I created the chart I pasted in in a cell. Now I want to be able to delete it by somehow referring to the cell I pasted it into. -- pwermuth ------------------------------------------------------------------------ pwermuth's Profile: http://www.excelforum.com/member.php...o&userid=24997 View this thread: http://www.excelforum.com/showthread...hreadid=386319 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
how to delete a chart using code?
You do not say if there are multiple charts, but if only one:
ActiveSheet.ChartObjects(1).Delete If there are multiple charts, the simplest method is to name the chart upon creation. With the name, it is easy to refer to the object later. ActiveSheet.ChartObjects(1).Name = "YourChart" -- Damon Longworth Don't miss out on the 2005 Excel User Conference Sept 16th and 17th Stockyards Hotel - Ft. Worth, Texas www.ExcelUserConference.com "pwermuth" wrote in message ... How do I delete a chart for which I do not have a name but only the cell the chart is anchored in using code? I.e. when I created the chart I pasted in in a cell. Now I want to be able to delete it by somehow referring to the cell I pasted it into. -- pwermuth ------------------------------------------------------------------------ pwermuth's Profile: http://www.excelforum.com/member.php...o&userid=24997 View this thread: http://www.excelforum.com/showthread...hreadid=386319 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
how to delete a chart using code?
Thank you for your help. The reason I did not name charts is that I am creating 50-100 at a time and then I do not touch them again in the same Macro. The Macro that is supposed to deleted them is a cleaning Macro so I do not see a way to pass the names of the charts to that Macro. -- pwermuth ------------------------------------------------------------------------ pwermuth's Profile: http://www.excelforum.com/member.php...o&userid=24997 View this thread: http://www.excelforum.com/showthread...hreadid=386319 |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
how to delete a chart using code?
I do not know your process, but you could name all charts that will be
deleted with a similar prefix. Something similar to: DelChart1 Then you could delete all charts that begin with "Del". -- Damon Longworth Don't miss out on the 2005 Excel User Conference Sept 16th and 17th Stockyards Hotel - Ft. Worth, Texas www.ExcelUserConference.com "pwermuth" wrote in message ... Thank you for your help. The reason I did not name charts is that I am creating 50-100 at a time and then I do not touch them again in the same Macro. The Macro that is supposed to deleted them is a cleaning Macro so I do not see a way to pass the names of the charts to that Macro. -- pwermuth ------------------------------------------------------------------------ pwermuth's Profile: http://www.excelforum.com/member.php...o&userid=24997 View this thread: http://www.excelforum.com/showthread...hreadid=386319 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Delete code | Excel Discussion (Misc queries) | |||
Delete an autostart Sub with code | Excel Programming | |||
Ron de Bruins Delete Row Code Q | Excel Programming | |||
VBA code delete code but ask for password and unlock VBA protection | Excel Programming | |||
VBA code to delete VBA code in another Workbook | Excel Programming |