ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Use macro to delete worksheet without specific name Eg:Sheet 1 (https://www.excelbanter.com/excel-programming/420170-use-macro-delete-worksheet-without-specific-name-eg-sheet-1-a.html)

Delight

Use macro to delete worksheet without specific name Eg:Sheet 1
 
Hello Everybody,

Need help again !! I need a macro to delete active worksheets without a
specific
worksheet name eg: Sheet7, Sheet8 & Sheet9, etc. I had tried this statement
but it don't work.. Is there anyone can help me ??

Activesheet.Delete

Thank You Very Much !!!



Bob Phillips[_3_]

Use macro to delete worksheet without specific name Eg:Sheet 1
 
Why and how doesn't it work?

--
__________________________________
HTH

Bob

"Delight" wrote in message
...
Hello Everybody,

Need help again !! I need a macro to delete active worksheets without a
specific
worksheet name eg: Sheet7, Sheet8 & Sheet9, etc. I had tried this
statement
but it don't work.. Is there anyone can help me ??

Activesheet.Delete

Thank You Very Much !!!





Gary''s Student

Use macro to delete worksheet without specific name Eg:Sheet 1
 
Sub JustKillMe()
Application.DisplayAlerts = False
ActiveSheet.Delete
Application.DisplayAlerts = True
End Sub

--
Gary''s Student - gsnu200814

Simon Lloyd[_930_]

Use macro to delete worksheet without specific name Eg:Sheet 1
 

I think a much better version of the code would be:

Sub Del_Sheets()
Dim sh As Worksheet
Application.DisplayAlerts = False
For Each sh In Sheets
If Left(sh.Name, 5) = "Sheet" Then
sh.Delete
End If
Next
Application.DisplayAlerts = True
End Sub


--
Simon Lloyd

Regards,
Simon Lloyd
'www.thecodecage.com' (http://www.thecodecage.com)
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=1
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=30854


Gary''s Student

Use macro to delete worksheet without specific name Eg:Sheet 1
 
Hi Simon;

That is an interesting interpretation of the question.
--
Gary''s Student - gsnu200814


"Simon Lloyd" wrote:


I think a much better version of the code would be:

Sub Del_Sheets()
Dim sh As Worksheet
Application.DisplayAlerts = False
For Each sh In Sheets
If Left(sh.Name, 5) = "Sheet" Then
sh.Delete
End If
Next
Application.DisplayAlerts = True
End Sub


--
Simon Lloyd

Regards,
Simon Lloyd
'www.thecodecage.com' (http://www.thecodecage.com)
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=1
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=30854



Delight

Use macro to delete worksheet without specific name Eg:Sheet 1
 
Hello Everybody,

Thanks for the help !! Simon, I followed your method and I get what I want.

Thanks !!


"Gary''s Student" wrote:

Hi Simon;

That is an interesting interpretation of the question.
--
Gary''s Student - gsnu200814


"Simon Lloyd" wrote:


I think a much better version of the code would be:

Sub Del_Sheets()
Dim sh As Worksheet
Application.DisplayAlerts = False
For Each sh In Sheets
If Left(sh.Name, 5) = "Sheet" Then
sh.Delete
End If
Next
Application.DisplayAlerts = True
End Sub


--
Simon Lloyd

Regards,
Simon Lloyd
'www.thecodecage.com' (http://www.thecodecage.com)
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=1
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=30854




All times are GMT +1. The time now is 07:30 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com