Thread: Delete Tabs
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ryan H Ryan H is offline
external usenet poster
 
Posts: 489
Default Delete Tabs

This code will find the index number of the Sheet named "Last". Then it will
delete all the sheets after that sheet without giving you the message box
alert. Hope this helps! If so, let me know, click "YES" below.

Option Explicit

Sub DeleteSheets()

Dim LastSheet As Long
Dim i As Long

Application.DisplayAlerts = False

LastSheet = Sheets("Last").Index + 1

For i = Sheets.Count To LastSheet Step -1
Sheets(i).Delete
Next i

Application.DisplayAlerts = True

End Sub

--
Cheers,
Ryan


"JohnUK" wrote:

Hi, I am after a piece of code that will delete all tabs regardless of names
and amounts after a certain tab. In this case the Tab is called €śLast€ť
Any ideas?
Many thanks