ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   need help, want to remove some sheets (https://www.excelbanter.com/excel-worksheet-functions/39291-need-help-want-remove-some-sheets.html)

Newbie80

need help, want to remove some sheets
 

Hi, I have some sheets that starts with the same substring and I want
all of them to be removed is there a simpel solution to this?

e.g
Thisworkbook.sheets("name-yyyy").delete exact match
The year differs so would like to remove all sheets that starts with:
Thisworkbook.sheets("name-").delete (multi delete if poss)


--
Newbie80
------------------------------------------------------------------------
Newbie80's Profile: http://www.excelforum.com/member.php...o&userid=25946
View this thread: http://www.excelforum.com/showthread...hreadid=393860


Bob Phillips

For Each sh In ThisWorkbook.Worksheets
If Left(sh.Name,5) = "name-" Then
if ThisWorkbook.Sheets.Count < 0 Then
Application.DisplayAlerts = false
sh.delete
Application.DisplayAlerts = True
End If
End If
Next sh

--
HTH

Bob Phillips

"Newbie80" wrote in
message ...

Hi, I have some sheets that starts with the same substring and I want
all of them to be removed is there a simpel solution to this?

e.g
Thisworkbook.sheets("name-yyyy").delete exact match
The year differs so would like to remove all sheets that starts with:
Thisworkbook.sheets("name-").delete (multi delete if poss)


--
Newbie80
------------------------------------------------------------------------
Newbie80's Profile:

http://www.excelforum.com/member.php...o&userid=25946
View this thread: http://www.excelforum.com/showthread...hreadid=393860





All times are GMT +1. The time now is 06:41 AM.

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