Thanks Thanks:  0
Likes Likes:  0
Results 1 to 5 of 5

Thread: Run module from user form

  1. #1
    New Member
    Join Date
    Jun 2017
    Posts
    3
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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
    812
    Post Thanks / Like
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    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
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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,632
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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
    812
    Post Thanks / Like
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    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.

User Tag List

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
  •  
This website uses cookies
We use cookies to store session information to facilitate remembering your login information, to allow you to save website preferences, to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners.
     


DMCA.com