Finding and Deleting a specified worksheet


Posted by Tam on May 03, 2000 7:15 AM

I'm looking for a Macro that can Find (amongst other worksheets)a Worksheet Tab (specified from a cell eg "A1") and then delete that sheet, overriding alert messages.

I've got stuck in loops and things.

Please help.

Much obliged,

Tamara X



Posted by Ivan Moala on May 03, 2000 7:43 AM

Tamara
Try this.

Sub DeleteSh()
Dim SheetName As String

'Select sheet with Name ref to delete
'In this case assume Sheet called "Main"
Sheets("Main").Select
SheetName = Range("A1").Text
Application.DisplayAlerts = False
On Error Resume Next
Sheets(SheetName).Select
If Err.Number = 9 Then MsgBox "Sheet doesn't exist": End
ActiveWindow.SelectedSheets.Delete

End Sub