Loading
Ozgrid Excel Help & Best Practices Forums

Excel Video Tutorials / Excel Dashboards Reports



Results 1 to 3 of 3

Thread: Calling Subroutine from UserForm

  1. #1
    Join Date
    17th April 2003
    Posts
    60

    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):

    VB:
    Public Sub Reset() 
         
        MsgBox ("Test") 
         
         'Clear out the partially entered data
        Worksheets("Input").Range("B2:B5").Value = "" 
        Worksheets("Input").Range("B7").Value = "" 
    End Sub 
    
    
    VB:
    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

    Excel Video Tutorials / Excel Dashboards Reports


  2. #2
    Join Date
    14th October 2004
    Posts
    104

    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

    Excel Video Tutorials / Excel Dashboards Reports


  3. #3
    Join Date
    17th April 2003
    Posts
    60

    [SOLVED] Re: Calling Subroutine from UserForm

    Maxihoya - that did it!

    Thanks a bunch...

    Excel Video Tutorials / Excel Dashboards Reports


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Possible Answers

  1. Calling A Subroutine
    By Configurator in forum EXCEL HELP
    Replies: 26
    Last Post: May 24th, 2007, 09:46
  2. Calling subroutine & carry value back
    By AbuYehya in forum EXCEL HELP
    Replies: 7
    Last Post: February 10th, 2006, 05:01
  3. calling subroutine
    By ljoseph in forum EXCEL HELP
    Replies: 4
    Last Post: April 2nd, 2005, 03:31
  4. Calling a subroutine in another workbook
    By mta37 in forum EXCEL HELP
    Replies: 1
    Last Post: January 12th, 2005, 04:48
  5. calling event subroutine
    By p_e_t_e_r in forum EXCEL HELP
    Replies: 3
    Last Post: August 21st, 2004, 04:01

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
porno