ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Delete chart without being prompted? (https://www.excelbanter.com/excel-programming/410212-delete-chart-without-being-prompted.html)

Herrick Andrews

Delete chart without being prompted?
 
Is there a way to delete a chart object via VBA code without it prompting me
if I really want to delete it? If I change the location of the chart so
it's embedded in a worksheet, and then delete it, I don't get prompted. But
I can't do that. I need to delete the chart while it's its own chart sheet
(not embedded in a worksheet). I created the chart programmatically.

The following two lines of code cause the problem every time for me.

Sub AddDeleteChartTest()
Dim c As Excel.Chart

Set c = Excel.Charts.Add

c.Delete ' I get a DialogBox saying "Data may exist in the sheet(s)
selected for deletion. To permanently delete the data, press Delete."
End Sub



Mark Ivey[_3_]

Delete chart without being prompted?
 
See if this will work...

Mark Ivey


Sub AddDeleteChartTest()
Dim c As Excel.Chart

Set c = Excel.Charts.Add

Application.DisplayAlerts = False

c.Delete

Application.DisplayAlerts = True

End Sub










"Herrick Andrews" <Herrick.Andrews@AT wrote in message
...
Is there a way to delete a chart object via VBA code without it prompting
me if I really want to delete it? If I change the location of the chart
so it's embedded in a worksheet, and then delete it, I don't get prompted.
But I can't do that. I need to delete the chart while it's its own chart
sheet (not embedded in a worksheet). I created the chart
programmatically.

The following two lines of code cause the problem every time for me.

Sub AddDeleteChartTest()
Dim c As Excel.Chart

Set c = Excel.Charts.Add

c.Delete ' I get a DialogBox saying "Data may exist in the sheet(s)
selected for deletion. To permanently delete the data, press Delete."
End Sub


Herrick Andrews[_2_]

Delete chart without being prompted?
 
Did the trick!! Thanks!!


"Mark Ivey" (do_not_spam) wrote in message
...
See if this will work...

Mark Ivey


Sub AddDeleteChartTest()
Dim c As Excel.Chart

Set c = Excel.Charts.Add

Application.DisplayAlerts = False

c.Delete

Application.DisplayAlerts = True

End Sub










"Herrick Andrews" <Herrick.Andrews@AT wrote in message
...
Is there a way to delete a chart object via VBA code without it prompting
me if I really want to delete it? If I change the location of the chart
so it's embedded in a worksheet, and then delete it, I don't get
prompted. But I can't do that. I need to delete the chart while it's its
own chart sheet (not embedded in a worksheet). I created the chart
programmatically.

The following two lines of code cause the problem every time for me.

Sub AddDeleteChartTest()
Dim c As Excel.Chart

Set c = Excel.Charts.Add

c.Delete ' I get a DialogBox saying "Data may exist in the sheet(s)
selected for deletion. To permanently delete the data, press Delete."
End Sub





All times are GMT +1. The time now is 01:51 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com