1

Issue: When I click a macro assigned button in my workbook the following error appeared:

"User-defined type not defined"

The error box appears, however, it did not highlight any code that may have produced the error. When I ran the macro from the compiler, the code executed without error. I was able to figure out that when I inserted a new button and assigned the same macro to the new button, the code executed without error.

Facts about the workbook:

  • The workbook includes multiple macros and multiple sheets as well as buttons linked to most of the macros (6 buttons)
  • The workbook is saved daily with a new date as modifications are made. The same button in previous workbooks do not produce this error.
  • There was an issue with one button a month ago and it was replaced, now a different button has this same issue. I would like to avoid replacing buttons every time this error occurs as I am not the end user.
  • This workbook was originally created in Excel 2010 but I have been using it in Excel 2013, though I made the switch months before this issue (not sure if info is relevant).

I saw a similar issue here, however the issue for me is not in my code, only in the form control. I would just like to know if anyone has seen this before and if there is a way to avoid needing to replace the buttons every time they "go bad."

12
  • So if you run the ..._Click() you don't get an error but when you click the button it does? Is the VBA project modified as well or just the sheet contents? Commented Sep 29, 2016 at 17:58
  • There must be a macro attached to that button which is causing the error to pop-up. Essentially, you need to debug this macro. If no particular line is highlighted then I (personally) like to take this approach: comment all lines in the macro and then test the button. Now it should work without a problem. Then start to uncomment a few lines and press the button again. Repeat and slowly uncomment all lines of code until you have found your culprit. Then post the code here and let us know what kind of VBA code can cause such errors. I'd like to know! Commented Sep 29, 2016 at 17:58
  • Open the Visual Basic Editor and select Debug->Compile VBAProject from the menu. It should jump you to the line with the error. Commented Sep 29, 2016 at 18:01
  • 1
    Do you have any add-ins installed? It sounds like there is an early bound reference somewhere that is missing. Commented Sep 29, 2016 at 18:19
  • 1
    Here is the practical approach to what @Comintern is saying: disable all add-ins and possibly also disable (if there is one) Personal.XLSB. Then see if you still get this error. If not, then he is right with his assumption. Start to re-enable one add-in at a time and see when you get the error again. Then check with the developer of that add-in what's causing the problem. Commented Sep 29, 2016 at 18:36

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.