Home |
Search |
Today's Posts |
#11
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Jim and everyone else for your responses. I got it to work so thank you!
"Jim Thomlinson" wrote: I think you need an And condition so that if it is not this sheet and it is not that sheet then delete the sheet. Boolean is a little funny when you use not = Sub DeleteSheets() Dim wks As Worksheet Application.DisplayAlerts = False For Each wks In Worksheets If wks.Name < "Product Names Data" and wks.Name < "Master Product Sheet" Then wks.Delete Next wks ErrorHandler: Application.DisplayAlerts = False End Sub -- HTH... Jim Thomlinson "hshayh0rn" wrote: I have some code that I thought would delete every sheet in a workbook except the two master sheets that can't be deleted but it's not working. I'm thinking the problem is with the OR part of the code. If I remove the OR then the code runs but the OR is pretty important so I'm look for some insight. Sub DeleteSheets() Dim wks As Worksheet Application.DisplayAlerts = False For Each wks In Worksheets If wks.Name < "Product Names Data" Or "Master Product Sheet" Then wks.Delete Next wks ErrorHandler: Application.DisplayAlerts = False End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Deleting Duplicate Records across multiple sheets | Excel Worksheet Functions | |||
deleting columns on multiple sheets | Excel Discussion (Misc queries) | |||
Deleting sheets | Excel Programming | |||
Deleting multiple Chart Tabs/sheets | Excel Programming | |||
Deleting Hyphens or Dashes from multiple cells without deleting the remaining content | Excel Programming |