Call Procedure From Add-in

  • I have a userform in an add-in (which is loaded), when I try and call it from an excel sheet, I get the following error "Variable not defined"


    Code
    Private Sub CommandButton3_Click()
    
    
    UserForm1.Show
    
    
    End Sub


    The code in the userform is all private subs.


    Similarly when calling a public sub from the add-in such as;


    Code
    Private Sub CommandButton3_Click()
    
    
    Call SillySub
    
    
    End Sub


    I get the error "Sub or Function not defined".


    How should I be doing this?

  • Re: Add-in Userform Gives Variable Not Defined


    You have to reference the file in which the form and/or Sub reside. Remember that they are still in a different workbook, even though it's an addin.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!