![]() |
exclusion list in code
I want to all delete sheets from my workbook except for ones that i specify.
This is what I had in mind. If I wanted to exclude say Sheet1, Sheet4, and Sheet7, how can I incorporate this into the following code? Can I call a function? Bruce Dim wkSht as WorkSheet For each wkSht in WorkSheets if wkSht < 'something' then wkSht.Delete next wkSht |
exclusion list in code
else
wkSht.Delete should be Case Else wksSht.Delete -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "AA2e72E" wrote in message ... Dim wkSht as WorkSheet For each wkSht in ActiveWorkbook.WorkSheets select case wkSht.Name case "keep1", "keep2", "keep3" ' do nothing else wkSht.Delete end select next wkSht You must keep at least one sheet i.e. a workbook must have at least one sheet. "Bruce" wrote: I want to all delete sheets from my workbook except for ones that i specify. This is what I had in mind. If I wanted to exclude say Sheet1, Sheet4, and Sheet7, how can I incorporate this into the following code? Can I call a function? Bruce Dim wkSht as WorkSheet For each wkSht in WorkSheets if wkSht < 'something' then wkSht.Delete next wkSht |
exclusion list in code
I bet that Chip was correcting the "Case Else" portion--not the wkSht portion.
Chip Pearson wrote: else wkSht.Delete should be Case Else wksSht.Delete -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "AA2e72E" wrote in message ... Dim wkSht as WorkSheet For each wkSht in ActiveWorkbook.WorkSheets select case wkSht.Name case "keep1", "keep2", "keep3" ' do nothing else wkSht.Delete end select next wkSht You must keep at least one sheet i.e. a workbook must have at least one sheet. "Bruce" wrote: I want to all delete sheets from my workbook except for ones that i specify. This is what I had in mind. If I wanted to exclude say Sheet1, Sheet4, and Sheet7, how can I incorporate this into the following code? Can I call a function? Bruce Dim wkSht as WorkSheet For each wkSht in WorkSheets if wkSht < 'something' then wkSht.Delete next wkSht -- Dave Peterson |
All times are GMT +1. The time now is 11:55 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com