Deleting Custom Views when Deleting Sheets

E

ExcelMonkey

I have a routine which deletes worksheets in a workbook. When I delete the
worksheets, I want to ensure that the custom views on those sheets are
deleted as well. Is there a way when deleting a sheet to test to see if it
has a custom view on that sheet? Does the view have a property that
identifies the sheet its on?

If not, is there a way to test to see if a custom view is still relevant? I
know that when I delete sheets, the views stay behind. If you try to
manually select the view an error message is NOT generated. As such its not
obvious that it no longer is relevant. The Show method below would not
generate an error message in VBA if the view it is attempting to show was
missing.

ActiveWorkbook.CustomViews("Condensed Consolidated Summary 1").Show

Thanks

EM
 
N

NickHK

CustomViews are not tied to a particular worksheet, as you can see from the
Object browser, as they are a member of Workbook.
Each view represents the appearance of all the WSs when the view is added.

So, even if a WS is deleted, it is still valid for the remaining WSs, albeit
with no visible change.
AFAIK there is no means to tell which WS/Cell/setting will be affected by
any particular CustomView.

NickHK
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top