Deleting Custom Views when Deleting Sheets
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 |
Deleting Custom Views when Deleting Sheets
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 "ExcelMonkey" wrote in message ... 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 |
All times are GMT +1. The time now is 02:36 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com