Announcement

Collapse
No announcement yet.

Unconfigured Ad Widget

Collapse

Calling Subroutine from UserForm

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Calling Subroutine from UserForm

    Greetings...

    I have 10 different UserForms in a workbook, all of which have a 'Cancel" button. When this is clicked on any of the 10 forms I want to clear parts of the input area (for example, cells B2:B5 and B7). I can do this now by coding this into the Cancel.Click event on the UserForm code but I have to enter the same code into each of the 10 forms. This is a problem if I need to update the areas to be cleared because I have to update all 10 forms.

    I wrote a module called Reset() in ThisWorkbook to accomplish the same thing but I cannot seem to call it from the UserForm Cancel.Click event. Relevant code is below (Reset first then the UserForm code):

    Code:
    Public Sub Reset()
    
    MsgBox ("Test")
    
    'Clear out the partially entered data
        Worksheets("Input").Range("B2:B5").Value = ""
        Worksheets("Input").Range("B7").Value = ""
    End Sub
    Code:
    Private Sub CmdCancel_Click()
    
    Call Reset
    
    'Kill the form
        Unload Me
        
    End Sub
    Thoughts? It's probably something simple but I can't seem to get it.

    Thanks,
    EB

  • #2
    Re: Calling Subroutine from UserForm

    The PROCEDURE needs to be placed in a MODULE (as oppose to a USERFORM) where it can be publicly accessed

    Comment


    • #3
      [SOLVED] Re: Calling Subroutine from UserForm

      Maxihoya - that did it!

      Thanks a bunch...

      Comment

      Trending

      Collapse

      There are no results that meet this criteria.

      Working...
      X