Stop excel form debugging - vba

I made a custom function in VBA, and when I called it from a cell, some error occurred. I am not able to edit the cell or save the file because excel is "debugging". If I try to edit excel cells, it gives a "beep", and if I try to save, it shows this dialog. I have tried pressing the blue square (reset) button in VBA many times. How do I stop this "debugging"?
Following is how VBA code looks like. The problem arose because I created a function named x(), and triggered it by calling ri() from a cell. After reading comments, I now know that I can stop debugging by renaming the function temporarily, but what is the right way to stop excel from "debugging"? I have also kept "Auto Syntax Check" unticked.
Following is the error message which appears on trying to save document.

Related

VBA IE.Document.All

I'm running a very simple Excel VBA code that goes to a website, and fills in a form (thousands of similar posts out there), however I need the box it's filling out to change based on a cell in my Excel file.
Right now the line of code I'm trying is:
IE.Document.All(Worksheets("sheet1").Range("a1")).Value = Worksheets("sheet1").Range("a2")
However whenever I try running it, I get a runtime error saying "Object Required". I'm guessing the IE.Document.All(Worksheets("sheet1").Range("a1")) part is not how I'm supposed to do it, so I'm hoping someone can provide me with the right way (I'm very new to VBA). The program works fine if I repalce that part with the Name of the box on the form (from inspect element), or it also works if the box A1 just has text in it, however the box I'm trying to pull has a formula that puts together a string of text

Excel VBA 2010 self reference a Active X button from within it's own action

i am trying to have an active X control in Excel 2010 get it's own alternate text and display it in a Text box when it is moused over.
If i use an absolute reference .Shapes("CommandButton1").AlternativeText it gets the text and i can do what i want with it, however i want a more dynamic function so the same code can be used on multiple buttons without edits so that it will always get the initiating button's own alt text.
I found this in my research, Self-referencing from inside an Excel VBA control
It seems like it would do what i need but when i run the module it throws a Runtime error 13, Type mismatch on this line Set shpButtons(btnCount).MyButton = shp.OLEFormat.Object.Object
If it matters i am trying to do this on a MouseMove event, however when i tested the code from the previous thread i was using direct clicks to see if it would would in the first place, which it did not, giving the Type mismatch error.
Any help getting this to work would be appreciated.
Thank you all so much in advance, lin.

"User-defined type not defined" error with button only, no code errors

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."

Run-time Error '32809' and Active X controls changed name

Huge problem here. I sent an excel form (a workbook with several sheets, thousands of active x controls and many many macros) to several people that they need to fill and return to me. Only one of the completed form I received is now completely impossible to use. All active X controls have changed name. If I select one I see the old name, but if I click on it the macro doesn't start and if I try to see its code it opens a new empty Macro with the new control name_click (Ex: a button called cmd_button1 opens a Macro called cmd_button2_click). When I start the Macro in VBA, I get the Run-time Error '32809' every time the code wants to unprotect sheets or to change the visible value of a sheet.
I looked on other posts and every solution I found would require a huge amount of work. What happened? Is there an easy solution to this?
Thank you.
I saved the workbook in .xlsx and copy/pasted all my macros back, transfered the forms and modules back then saved it back to .xlsm and now the buttons call the macros and no run time errors occur anymore.

CommandButton Clicking vs Executing from VBA Editor,

If you have look at these two captured images...
Basically, stepping into the next line should not change the selected tab as shown here. This is what happens if I click F5 from the VBA Editor to execute the sub
But when I actually run it using a linked command button which suppose to be doing the exactly same thing (photo shown down the thread). but what happens is this,
Stepping into the next line actually somehow changes the tab!
There is noting in the first break point line that tells excel to select another tab... why is this doing this.
if I run it using F8, actually this problems goes away.
UPDATED=============================================================
I come across some weird behaviour in the Excel VBA and can't explain why its doing it.
Sub run_simulation()
ActiveWorkbook.Worksheets("Run Simulation").Select
ActiveSheet.CommandButton1.value = True
End Sub
This subroutine selects a sheets then simulates the clicking of a button 'CommandButton1'.
When I execute this from the play icon within the VBA Editor it runs fine but when I run this 'run_simulation' subroutine from a linked button on another sheet... like this
an error returns saying that the selected sheet "run_simulation" is protected and needs to be unprotected before proceeding... the thing is it unprotects the sheets automatically when the commandButton1 is clicked.
The Worksheet.Protect method has a little-used UserInterfaceOnly parameter.
From MSDN:
UserInterfaceOnly (optional) - True to protect the user interface, but not macros. If this argument is omitted, protection applies both to macros and to the user interface.
Set this to True when setting the worksheet protection and you will be able to manipulate the worksheet objects programmatically.