#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 173
Default Delete Tabs

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 173
Default Delete Tabs

Fantastic!!
Many thanks Ryan

"Ryan H" wrote:

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2002: Can I delete tabs at one go ? Mr. Low Excel Discussion (Misc queries) 2 July 24th 09 05:16 PM
Not a novice - can't delete tabs! Sherri Excel Discussion (Misc queries) 1 April 9th 09 02:36 PM
Delete Tabs Ardy Excel Programming 7 December 10th 06 01:56 AM
Delete Tabs dogpigfish Excel Programming 1 December 29th 05 06:56 PM
Macro to force delete tabs Randy[_11_] Excel Programming 1 August 13th 04 04:43 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright 2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"