Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Search and Delete
Hi all
I need to search through a wookbook for a chart and then if it is there, delete it. Any ideas as to how to do this? I have tried this but it doesn't work right. Set wSheet = Sheets(strSurfPlotName) If wSheet Is Nothing Then 'Doesn't exist Set wSheet = Nothing On Error GoTo 0 Else 'Does exist Application.DisplayAlerts = False Charts(strSurfPlotName).Delete Application.DisplayAlerts = True Set wSheet = Nothing On Error GoTo 0 End If it doesn't search right. Thanks - Ben H |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Search and Delete
Dim wSheet as Chart Dim ch as Chart Dim strSurfPlotName as String strSurfPlotName = "MyChart" On Error Resume Next Set wSheet = Sheets(strSurfPlotName) On Error goto 0 If wSheet Is Nothing Then 'Doesn't exist for each ch in Activeworkbook.Charts if instr(1,ch.name, strSurfPlotName,vbTextCompare) then ans = msgbox( ch.Name & " appears a close match" _ vbNewLine & "Delete?", vbYesNo) if ans = vbYes then Application.DisplayAlerts = False ch.Delete Application.DisplayAlerts = True end if end if Next ch Else 'Does exist Application.DisplayAlerts = False Charts(strSurfPlotName).Delete Application.DisplayAlerts = True Set wSheet = Nothing End If -- Regards, Tom Ogilvy "Ben H" wrote: Hi all I need to search through a wookbook for a chart and then if it is there, delete it. Any ideas as to how to do this? I have tried this but it doesn't work right. Set wSheet = Sheets(strSurfPlotName) If wSheet Is Nothing Then 'Doesn't exist Set wSheet = Nothing On Error GoTo 0 Else 'Does exist Application.DisplayAlerts = False Charts(strSurfPlotName).Delete Application.DisplayAlerts = True Set wSheet = Nothing On Error GoTo 0 End If it doesn't search right. Thanks - Ben H |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Search and Delete
Tom
You the man on this stuff. Fixed it on the first try! Thank you greatly! Ben H. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
keyword search and delete row | Excel Discussion (Misc queries) | |||
SEARCH AND DELETE | Excel Programming | |||
Need help: search and delete columns | Excel Programming | |||
Add-in to search and delete | Excel Programming | |||
Search and Delete | Excel Programming |