Results 1 to 5 of 5

Run module from user form

This is a discussion on Run module from user form within the Excel Questions forums, part of the Question Forums category; How do i run a module from a userform. Is there a specific code i use or do i simply ...

  1. #1
    New Member
    Join Date
    Jun 2017
    Posts
    3

    Default Run module from user form

    How do i run a module from a userform. Is there a specific code i use or do i simply write call module1?

  2. #2
    Board Regular Logit's Avatar
    Join Date
    Aug 2016
    Location
    United States
    Posts
    696

    Default Re: Run module from user form

    Presuming you are using a CommandButton on the UserForm to fire the macro ...

    Doubleclick the command button. In the sub that appears, call the macro from there.

  3. #3
    New Member
    Join Date
    Jun 2017
    Posts
    3

    Default Re: Run module from user form

    Thank you..... Would i just write for example
    Sub button
    Call module1
    Endsub?

  4. #4
    Board Regular My Aswer Is This's Avatar
    Join Date
    Jul 2014
    Posts
    9,096

    Default Re: Run module from user form

    It would look like this:

    Code:
    Private Sub CommandButton1_Click()
    Call Macro1
    End Sub
    Be sure and always test this script on sample data the first time you use this as to avoid any problems with your data. Always trying to learn more and help others where I can. I'm using Excel 2013.
    Patience please Iím not perfect yet. "Memories are forever"

  5. #5
    Board Regular Logit's Avatar
    Join Date
    Aug 2016
    Location
    United States
    Posts
    696

    Default Re: Run module from user form

    Thank you..... Would i just write for example
    Sub button
    Call module1
    Endsub?
    Yes ... but don't call your macro "button". Try to avoid using key words that Excel recognizes as standard commands or name of objects.

    You could do :
    Code:
     
    Sub CommandButton1_Click()
        Call MyMac1
    
    End Sub
    Last edited by Logit; Jun 19th, 2017 at 08:20 PM.

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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


DMCA.com