简体   繁体   中英

Excel Sheet Suddenly Won't Run VBA Code - Works on 'Some' Other Machines - Duplicated Sheet Works Fine

I have an issue with my Excel workbook. I have code both in modules and embedded in the sheet.

Until recently, everything was working fine but suddenly the code embedded in the sheet does not work.

I have a sub routine for right clicked cells. This used to create a drop-down menu of its own rather than the standard right click menu but recently it stopped working. I have tried deleting the entire code and simply putting msgbox("Test") , but it still doesn't work.

Macros are enabled as this is the interesting thing ... if I right click the sheet tab and copy it ... the new version works absolutely fine. It is as if the original sheet has become corrupt.

This is further evidenced by when I try to delete the original sheet manually (right click tab and delete).

This causes Excel to crash.

I can delete any other sheet no problems.

However, a colleague of mine opened the workbook and it works fine for him without having to duplicate the sheet.

When it first happened I did the duplicate fix then renamed the original to "OBSOLETE". Not a pretty workaround, but worked nevertheless.

It has now happened again, however, and I am reluctant to keep patching it in this way.

If I try to address the sheet using VBA from another sheet:

Code in sheet 2 ("Slave"): msgbox(sheets("Master").cells(1,1).value)

it gives the following error:

Run-time error 32809: Application-defined or object-defined error

I have tried addressing it as sheet1.cells instead of sheets("Master").cells as well and this gives the same error.

Changing the code to point to Sheet3 works fine. It is literally just this sheet causing problems.

I tried 'open and repair' on the document too.

I have read around extensively and tried the deletion of .exd files etc. No luck.

Any thoughts? It seems independent of code - more a specific issue with this workbook and its sheet which over time becomes 'corrupt' but only for some machines/users.

There is also a command button in the sheet. This also does not work (clicking it just does nothing). If I go into the VBA editor and manually activate the sub-routine, I get the following error:

Compile error:

Object library invalid or contains references to object definitions that could not be found.

Again, this still happens even if I strip the code right down to a simple msgbox operation.

Any thoughts would be appreciated. Thanks

Hi i am having the same issue running code that populates combo boxes on my sheet. It seems that the sheet index is being deleted so the workbook o longer 'sees' the sheet you are trying to reference.

A simple workaround i found is to resave the workbook with a different name and it should work fine but this is not ideal when it is running on a regular basis. It does however allow you to recover the original workbook after it has been corrupted on the other machine.

It seems that some security updates made by microsoft in December 2014 have resulted in issues running sheets across the old and new machines. They are aware of the issue and are working to resolve it. This blog explains the issues and work arounds: http://blogs.technet.com/b/the_microsoft_excel_support_team_blog/archive/2014/12/11/forms-controls-stop-working-after-december-2014-updates-.aspx

Their solution provided on the above blog requires all users to have this update and then to delete all .exd files from the temp folder that are related to the issue and then recompile the code (this still requires all machines to have the new update).

Another option (the one I will be taking until they resolve the issue) is to roll back the problem machines to a pre Dec version prior to making the update.

Hope that helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM