Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 506
Default VBA Code Required for deleting All Sheets except Sheet1

Please help to delete all the sheets in a workbook except the First sheet
(i.e.) Sheet1.

Thanks for reading.

--------------------
(Ms-Exl-Learner)
--------------------

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 896
Default VBA Code Required for deleting All Sheets except Sheet1

Sub delsheets()
Dim sh as Sheet

For Each sh in ActiveWorkbook.Sheets
If sh.Name<"Sheet1" Then
sh.Delete
End If
Next sh

End Sub

On 3 Lis, 09:46, Ms-Exl-Learner wrote:
Please help to delete all the sheets in a workbook except the First sheet
(i.e.) Sheet1.

Thanks for reading.

--------------------
(Ms-Exl-Learner)
--------------------


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 896
Default VBA Code Required for deleting All Sheets except Sheet1

forgot to include the

Application.DisplayAlerts = False
....
Application.DisplayAlerts = True

part


On 3 Lis, 10:10, Jarek Kujawa wrote:
Sub delsheets()
Dim sh as Sheet

For Each sh in ActiveWorkbook.Sheets
If sh.Name<"Sheet1" Then
sh.Delete
End If
Next sh

End Sub

On 3 Lis, 09:46, Ms-Exl-Learner wrote:



Please help to delete all the sheets in a workbook except the First sheet
(i.e.) Sheet1.


Thanks for reading.


--------------------
(Ms-Exl-Learner)
--------------------- Ukryj cytowany tekst -


- Pokaż cytowany tekst -


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default VBA Code Required for deleting All Sheets except Sheet1

Sub SheetRemover()
k = Sheets.Count
For i = k To 2 Step -1
Sheets(i).Delete
Next
End Sub

--
Gary''s Student - gsnu200908


"Ms-Exl-Learner" wrote:

Please help to delete all the sheets in a workbook except the First sheet
(i.e.) Sheet1.

Thanks for reading.

--------------------
(Ms-Exl-Learner)
--------------------

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 506
Default VBA Code Required for deleting All Sheets except Sheet1

Thank you its working fine but if I run the Macro then its asking me to
Confirm Do you want to delete this sheet like that for each and every
worksheet before deleting. I am having 200 sheets for 200 times I need to
click or Press enter for deleting the sheets.

Please help me€¦

--------------------
(Ms-Exl-Learner)
--------------------



"Gary''s Student" wrote:

Sub SheetRemover()
k = Sheets.Count
For i = k To 2 Step -1
Sheets(i).Delete
Next
End Sub

--
Gary''s Student - gsnu200908


"Ms-Exl-Learner" wrote:

Please help to delete all the sheets in a workbook except the First sheet
(i.e.) Sheet1.

Thanks for reading.

--------------------
(Ms-Exl-Learner)
--------------------



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 506
Default VBA Code Required for deleting All Sheets except Sheet1

Not for 200 times 199 times. Please set the macro without any message box
confirmation.

--------------------
(Ms-Exl-Learner)
--------------------



"Ms-Exl-Learner" wrote:

Thank you its working fine but if I run the Macro then its asking me to
Confirm Do you want to delete this sheet like that for each and every
worksheet before deleting. I am having 200 sheets for 200 times I need to
click or Press enter for deleting the sheets.

Please help me€¦

--------------------
(Ms-Exl-Learner)
--------------------



"Gary''s Student" wrote:

Sub SheetRemover()
k = Sheets.Count
For i = k To 2 Step -1
Sheets(i).Delete
Next
End Sub

--
Gary''s Student - gsnu200908


"Ms-Exl-Learner" wrote:

Please help to delete all the sheets in a workbook except the First sheet
(i.e.) Sheet1.

Thanks for reading.

--------------------
(Ms-Exl-Learner)
--------------------

  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default VBA Code Required for deleting All Sheets except Sheet1

Sub SheetRemover()
k = Sheets.Count
Application.DisplayAlerts = False
For i = k To 2 Step -1
Sheets(i).Delete
Next
Application.DisplayAlerts = True
End Sub


--
Gary''s Student - gsnu200908


"Ms-Exl-Learner" wrote:

Not for 200 times 199 times. Please set the macro without any message box
confirmation.

--------------------
(Ms-Exl-Learner)
--------------------



"Ms-Exl-Learner" wrote:

Thank you its working fine but if I run the Macro then its asking me to
Confirm Do you want to delete this sheet like that for each and every
worksheet before deleting. I am having 200 sheets for 200 times I need to
click or Press enter for deleting the sheets.

Please help me€¦

--------------------
(Ms-Exl-Learner)
--------------------



"Gary''s Student" wrote:

Sub SheetRemover()
k = Sheets.Count
For i = k To 2 Step -1
Sheets(i).Delete
Next
End Sub

--
Gary''s Student - gsnu200908


"Ms-Exl-Learner" wrote:

Please help to delete all the sheets in a workbook except the First sheet
(i.e.) Sheet1.

Thanks for reading.

--------------------
(Ms-Exl-Learner)
--------------------

  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 506
Default VBA Code Required for deleting All Sheets except Sheet1

Thank you very much its working fine now€¦

--------------------
(Ms-Exl-Learner)
--------------------



"Gary''s Student" wrote:

Sub SheetRemover()
k = Sheets.Count
Application.DisplayAlerts = False
For i = k To 2 Step -1
Sheets(i).Delete
Next
Application.DisplayAlerts = True
End Sub


--
Gary''s Student - gsnu200908


"Ms-Exl-Learner" wrote:

Not for 200 times 199 times. Please set the macro without any message box
confirmation.

--------------------
(Ms-Exl-Learner)
--------------------



"Ms-Exl-Learner" wrote:

Thank you its working fine but if I run the Macro then its asking me to
Confirm Do you want to delete this sheet like that for each and every
worksheet before deleting. I am having 200 sheets for 200 times I need to
click or Press enter for deleting the sheets.

Please help me€¦

--------------------
(Ms-Exl-Learner)
--------------------



"Gary''s Student" wrote:

Sub SheetRemover()
k = Sheets.Count
For i = k To 2 Step -1
Sheets(i).Delete
Next
End Sub

--
Gary''s Student - gsnu200908


"Ms-Exl-Learner" wrote:

Please help to delete all the sheets in a workbook except the First sheet
(i.e.) Sheet1.

Thanks for reading.

--------------------
(Ms-Exl-Learner)
--------------------

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
Form Code Required John Calder New Users to Excel 3 October 27th 09 10:29 PM
Another VB Code Required TGV Excel Discussion (Misc queries) 7 February 7th 09 07:21 AM
VB Code Required TGV Excel Discussion (Misc queries) 3 February 6th 09 05:31 PM
code is not to work on sheet1 Allan R Jeffery New Users to Excel 3 August 22nd 06 02:22 PM
How do I set up a workbook so changing Sheet1 changes all sheets? rach1027 Excel Worksheet Functions 1 June 7th 05 10:12 AM


All times are GMT +1. The time now is 03:47 PM.

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"