VBA-xlsm 文件有错误 40036,具有相似的工作表名称
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24690421/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
VBA- xlsm file has error 40036 with similar sheet names
提问by user3827978
i have an issues with an macro that i'm writing. I have my xlsm file that i'm writing my macro in, it's creating a template that gets data from multiple spreadsheets that other people send me. However one file that i use for information is an xlsm file and is giving me problems. I believe i have isolated the problem but am unsure as to how to fix it.
我正在编写的宏有问题。我有我正在编写宏的 xlsm 文件,它正在创建一个模板,该模板从其他人发送给我的多个电子表格中获取数据。但是,我用于提供信息的一个文件是 xlsm 文件,这给我带来了问题。我相信我已经隔离了这个问题,但我不确定如何解决它。
the first sheet is named "Piranha" (no idea why), and the second sheet is named "Piranha - Dist & Growth split"
第一张纸被命名为“Piranha”(不知道为什么),第二张纸被命名为“Piranha - Dist & Growth split”
however when i write stardard code like Sheets("Piranha").select
但是,当我编写像 Sheets("Piranha").select 这样的标准代码时
it has a runtime error 40036 (Application- defined or object defined error)
它有一个运行时错误 40036(应用程序定义或对象定义错误)
it also doesn't like ActiveSheet.select / .name
它也不喜欢 ActiveSheet.select / .name
but only for those two sheets, there is another sheet named "Exceptions" and i can use that object no problem. Has anyone ever heard of this problem or better have any ideas on how to solve it? Also because it's not my file if there is a way to do it without actually altering the file would be amazing. Thank you!
但仅对于这两个工作表,还有另一个名为“例外”的工作表,我可以使用该对象没问题。有没有人听说过这个问题,或者更好地对如何解决它有任何想法?也因为它不是我的文件,如果有一种方法可以在不实际更改文件的情况下做到这一点,那就太棒了。谢谢!
回答by user3827978
Thanks guys for your help, however i fiiiinally figured out that when trying to manipulate the file to get the data the macro of the file would interfere with my process, so i just make a copy of the file and delete all vb components and my code works fine
感谢大家的帮助,但是我最终发现,在尝试操作文件以获取数据时,文件的宏会干扰我的进程,所以我只是复制文件并删除所有 vb 组件和我的代码工作正常
回答by Yani
I had similar problem error 40036 and debugging pointed to a file path variable. When deleting or adding line of code the error moved...
我有类似的问题错误 40036,调试指向文件路径变量。删除或添加代码行时,错误移动了...
I tried solution from Expert Exchange:
我尝试了 Expert Exchange 的解决方案:
from VBA window do Debug>Compile VBAProject
fix any error raised
I fixed the error and it all works fine now :)
我修复了错误,现在一切正常:)
回答by barrowc
In the file which is a problem, try compiling the VBA project (via Debug > Compile VBA Project in the VBA editor) and see if there is an error in any code in the relevant sheet modules
在有问题的文件中,尝试编译 VBA 项目(通过 VBA 编辑器中的 Debug > Compile VBA Project)并查看相关工作表模块中的任何代码是否有错误
回答by SilverShotBee
Sub test()
Sheets("Sheet1 & 2").Select
ActiveSheet.Select
End Sub
Sub test2()
Sheets("Sheet1").Select
ActiveSheet.Select
End Sub
Tested your issue with the above code and I was unable to replicate your fault. Perhaps there is a space at the beginning or end of one of the sheets? As for ActiveSheet not working, it works OK in my test. I think you need to check your code, or at least update your Question with your code so we can check it
使用上述代码测试了您的问题,但我无法复制您的错误。也许其中一张纸的开头或结尾有一个空格?至于 ActiveSheet 不工作,它在我的测试中工作正常。我认为您需要检查您的代码,或者至少用您的代码更新您的问题,以便我们进行检查