Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete worksheets

Status
Not open for further replies.

sanjna000

Programmer
Aug 1, 2003
132
0
0
GB
Hi,

i need to delete extra worksheets in my workbook.

Sheets("Sheet1").Delete false

this generated an error.

Pls can anyone help me with this!

I really appriciate u r help

Thanks a lot for u r help in advance...
Sanjna...
 
Application.DisplayAlerts = False
Sheets("Sheet1").Delete
Application.DisplayAlerts = True
 
If it is a particular sheet you want to keep but lose all the others then you could just loop through:-

Code:
Sub DelShts()
Application.DisplayAlerts = False
  For Each Sheet In ActiveWorkbook.Sheets
    If Sheet.Name <> "Keep Me" Then
       Sheet.Delete
    End If
 Next
Application.DisplayAlerts = True
End Sub

Regards
Ken.................

----------------------------------------------------------------------------
[peace]It's easier to beg forgiveness than ask permission[2thumbsup]

----------------------------------------------------------------------------
 
Thanks guys,

It works perfectly!

Cheers,
Sanjna...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top