I've had an Excel VBA addin I've developed over many years. Many users have used this addin on Windows on both Excel 2007 and Excel 2010; it has even worked on Macbook. For the first time, a user is getting an error in Windows Excel 2010 when clicking a button I've added to a ribbon to bring up a form.
The error is 'Compile error: Variable not defined'. I am using Option Explicit throughout the code, but there is no variable being defined when the userform initializes. I've compiled from within the VBA editor using Debug...Compile VBAProject and get no errors. I've googled this and read many posts but nowhere has this error been associated with a userform initializing.
I have this code in the click event of a button I've added to a new ribbon:
Sub DisplayForm4Calc1(ByVal control As IRibbonControl)
On Error Resume Next
frmAA.Show
End Sub
I have this code in frmAA, just initializing some controls:
Option Explicit
Public myPrevious As Boolean
Private Sub UserForm_Initialize()
On Error Resume Next
refNumerator.value = ""
refDenominator.value = ""
MultiPage.value = 3
End Sub
The error is highlighting the line 'Private Sub UserForm_Initialize()'.
F8
in debugging to step through the code and identify which line actually raises the error. Also, get rid of yourOn Error Resume Next
statements. – David Zemens Jul 13 '16 at 18:25MultiPage
control may trigger that control's_Change
event, too, so the error may be in that function. – David Zemens Jul 13 '16 at 18:26On Error Resume Next
statements and they're testng it again. And, there is no_Change
event on theMultiPage
control. – MattB Jul 13 '16 at 21:57On Error Resume Next
lines and it worked for them. I will investigate more especially given the advice from @Yow. But it's great that they can use it. Thanks! – MattB Jul 14 '16 at 20:01