Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Running multiple macros with one command button on userform
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    Board Regular ExcelNovice's Avatar
    Join Date
    May 2002
    Posts
    573
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Running multiple macros with one command button on userform

    Hi, I'm trying to run the following macros from a userform but continues to get an error each time I try:

    Private Sub CommandButton1_click()
    Call Worksheets("Sheet1").CommandButton11_click
    Call Worksheets("Sheet1").CommandButton12_click
    Call Worksheets("Sheet1").CommandButton13_click
    Call Worksheets("Sheet1").CommandButton14_click

    End Sub

    The error received is:

    Run-time error '438'
    Object doesn't support this property or method

    Thanks for your help.
    We refused to be what they wanted us to be, we are what we are, and that's the way it's going to be.....
    Babylon System - Bob Marley and the Wailers

  2. #2
    Board Regular My Aswer Is This's Avatar
    Join Date
    Jul 2014
    Posts
    15,887
    Post Thanks / Like
    Mentioned
    28 Post(s)
    Tagged
    13 Thread(s)

    Default Re: Running multiple macros with one command button on userform

    All those Private Sheet scripts change them to Public like this:
    Code:
    Public Sub CommandButton1_Click()
    MsgBox "Hello"
    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"

  3. #3
    Board Regular ExcelNovice's Avatar
    Join Date
    May 2002
    Posts
    573
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Running multiple macros with one command button on userform

    Thanks, but still doesn't work.
    We refused to be what they wanted us to be, we are what we are, and that's the way it's going to be.....
    Babylon System - Bob Marley and the Wailers

  4. #4
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    29,177
    Post Thanks / Like
    Mentioned
    483 Post(s)
    Tagged
    49 Thread(s)

    Default Re: Running multiple macros with one command button on userform

    Are those commandbuttons on a sheet called sheet1?
    And are they ActiveX command buttons?
    Last edited by Fluff; Sep 21st, 2019 at 10:09 AM.
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 365 on Win 10

  5. #5
    Board Regular ExcelNovice's Avatar
    Join Date
    May 2002
    Posts
    573
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Running multiple macros with one command button on userform

    Fluff, that is correct.
    We refused to be what they wanted us to be, we are what we are, and that's the way it's going to be.....
    Babylon System - Bob Marley and the Wailers

  6. #6
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    29,177
    Post Thanks / Like
    Mentioned
    483 Post(s)
    Tagged
    49 Thread(s)

    Default Re: Running multiple macros with one command button on userform

    In that case as long as your removed the "Private" from the start of the procedure names. Your code should work.
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 365 on Win 10

  7. #7
    Board Regular My Aswer Is This's Avatar
    Join Date
    Jul 2014
    Posts
    15,887
    Post Thanks / Like
    Mentioned
    28 Post(s)
    Tagged
    13 Thread(s)

    Default Re: Running multiple macros with one command button on userform

    Show us the actual scripts. There may be something wrong with the scripts.
    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"

  8. #8
    Board Regular ExcelNovice's Avatar
    Join Date
    May 2002
    Posts
    573
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Running multiple macros with one command button on userform

    This is the code I'm using...

    Public Sub CommandButton1_Click()

    Call Sheets("Sheet1").CommandButton11_Click 'Macro1
    Call Sheets("Sheet1").CommandButton12_Click 'Macro2
    Call Sheets("Sheet1").CommandButton13_Click 'Macro3
    Call Sheets("Sheet1").CommandButton14_Click 'Macro4

    End Sub
    We refused to be what they wanted us to be, we are what we are, and that's the way it's going to be.....
    Babylon System - Bob Marley and the Wailers

  9. #9
    Board Regular My Aswer Is This's Avatar
    Join Date
    Jul 2014
    Posts
    15,887
    Post Thanks / Like
    Mentioned
    28 Post(s)
    Tagged
    13 Thread(s)

    Default Re: Running multiple macros with one command button on userform

    I want to see the code in the Button.

    The button must have some code in it.
    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"

  10. #10
    Board Regular ExcelNovice's Avatar
    Join Date
    May 2002
    Posts
    573
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Running multiple macros with one command button on userform

    Got it, here you go....thanks for your help.

    Private Sub CommandButton11_Click()
    If Range("os56") = 0 Then
    Range("AA81:AA81").Select
    Range("AA81:AA81").Activate
    Selection.RowHeight = 0.000001
    Range("AA82:AA82").Select
    Range("AA82:AA82").Activate
    Selection.RowHeight = 0.000001
    Range("AA83:AA83").Select
    Range("AA83:AA83").Activate
    Selection.RowHeight = 0.000001

    Range("os56") = 4
    Else
    Range("AA81:AA81").Select
    Range("AA81:AA81").Activate
    Selection.RowHeight = 12.75
    Range("AA82:AA82").Select
    Range("AA82:AA82").Activate
    Selection.RowHeight = 12.75
    Range("AA83:AA83").Select
    Range("AA83:AA83").Activate
    Selection.RowHeight = 13.5

    Range("os56") = 0
    End If
    End Sub
    We refused to be what they wanted us to be, we are what we are, and that's the way it's going to be.....
    Babylon System - Bob Marley and the Wailers

Some videos you may like

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
  •