Remove a non-existant Sheet in VBA

南楼画角 提交于 2021-02-05 05:11:24

问题


I have sheets listed in an Excel Workbook that don't actually exist. The sheets are listed when you view code and are looking at the list of sheets in the VBA part, but they don't actually exist in the workbook at all. They also aren't hidden, in case someone is thinking of that.

These sheets also don't have a name after them in parentheses and look like the same icon as ThisWorkbook. I have no way to delete them and have been trying. Does anyone have any suggestions on how to delete them from the VBA portion? Remember, these sheets don't actually exist so it's not like I can just right click on them within Excel and select Delete. I did try right clicking on the sheet in VBA and select Remove Sheet, but that option is greyed out. Actually remove sheet is greyed out on all sheets, even those that do exist. The spreadsheet is not protected in any way either.

These sheets aren't causing any issues, more of an annoyance since I know they aren't physically there and I have no way to remove them from VBA.I have attached a picture of what I am looking at. The sheets that I am trying to remove are Sheet10, Sheet11, and Sheet9.

enter image description here


回答1:


I had that same situation once. The only solution I found was to copy all of the "real" worksheets to a new workbook. I'm guessing the original workbook got corrupted somehow.




回答2:


I solved a problem like this doing the next steps:

  1. Backup your file in other place
  2. Change the extension .xlsm to .zip
  3. Extract the zip file
  4. Go to /xl folder
  5. Open workbook.xml in notepad
  6. In some place there was each "gost" Sheet with the parameter hidden. Replace full command parameter by nothing (I don't remember the structure. Something like 'state:"hidden"'. Erase all of this)
  7. Compact all files and folders extracted as ZIP.
  8. Rename the zip file as .xlsm
  9. Open and see if it's resolved



回答3:


There is an easier way.... Right-click on one of the current tabs and select 'Unhide'. This will display a list of all your 'hidden' tabs. Unhide them, then delete them. Once deleted, they will be removed from the VBAProject list.




回答4:


I know this is an old post, but I found the solution. if you look at the properties of the 'Phantom' sheet you will notice its 'visible' property is 2 - xlSheetVeryHiddden. Just change that property to -1 - xlsheetVisible and you will be able to delete it.



来源:https://stackoverflow.com/questions/24497772/remove-a-non-existant-sheet-in-vba

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!