在VBA中删除不存在的工作表 [英] Remove a non-existant Sheet in VBA

查看:96
本文介绍了在VBA中删除不存在的工作表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Excel工作簿中列出了实际上并不存在的工作表.当您查看代码并查看VBA部分中的工作表列表时,工作表将列出,但实际上它们根本不存在于工作簿中.如果有人想到了它们,它们也不会被隐藏.

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.

这些工作表的括号后也没有名称,看起来像与ThisWorkbook相同的图标.我无法删除它们,并且一直在尝试.有人对如何从VBA部分删除它们有任何建议吗?记住,这些工作表实际上并不存在,所以我不能在Excel中右键单击它们并选择删除".我确实尝试在VBA中的工作表上单击鼠标右键,然后选择删除工作表",但是该选项显示为灰色.实际删除的工作表在所有工作表上都显示为灰色,即使存在的工作表也是如此.电子表格也没有受到任何保护.

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.

这些工作表不会造成任何问题,更令人烦恼的是,因为我知道它们并不实际存在,并且我无法将它们从VBA中删除.我已附上一张我正在查看的图片.我要删除的工作表是Sheet10,Sheet11和Sheet9.

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.

推荐答案

我曾经遇到过同样的情况.我发现的唯一解决方案是将所有真实"工作表复制到新工作簿中.我猜原来的工作簿因某种原因被破坏了.

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.

这篇关于在VBA中删除不存在的工作表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆