+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 19

Thread: Run different macros simultaneously.

  1. #1
    Registered User
    Join Date
    09-19-2011
    Location
    Porto, Portugal
    MS-Off Ver
    Excel 2003
    Posts
    8

    Run different macros simultaneously.

    Hi.
    I am using excel 2010 and I’m facing a problem. Maybe someone can help me.

    I have created 3 different macros, but I want to run them with only one click.

    The big problem is that the second macro should run only when the first is finished, and the third should only run when the second is finished.

    Any tip?

    Regards:
    Bruno

  2. #2
    Forum Guru TMShucks's Avatar
    Join Date
    07-15-2010
    Location
    Manchester, England
    MS-Off Ver
    MSO 2003 & 2007
    Posts
    6,222

    Re: Run different macros simultaneously.

    Sub Main()
    Macro1
    Macro2
    Macro3
    End Sub
    
    Sub Macro1()
    MsgBox 1
    Exit Sub
    
    Sub Macro2()
    MsgBox 2
    Exit Sub
    
    Sub Macro3()
    MsgBox 3
    Exit Sub


    Regards

  3. #3
    Registered User
    Join Date
    09-19-2011
    Location
    Porto, Portugal
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Run different macros simultaneously.

    To assign this command to a button, I only have to copy that command, changing the macros name, isn't it?
    But it don't work

  4. #4
    Forum Guru, retired Admin royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    25,637

    Re: Run different macros simultaneously.

    You just run Main from the button
    Hope that helps.

    RoyUK
    --------
    If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need

    For Excel Tips & Solutions, free examples and tutorials why not check out my downloads

    New members please read & follow the Forum Rules

    Remember to mark your questions Solved and rate the answer(s)

  5. #5
    Registered User
    Join Date
    09-19-2011
    Location
    Porto, Portugal
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Run different macros simultaneously.

    Hi,

    This code don't solve my problem!

    My first macro takes too long to be updated, and the second one should only start when the first one is conclude.

    The biggeste problem is the second macro starts when the first one is still running.

  6. #6
    Registered User
    Join Date
    09-19-2011
    Location
    Porto, Portugal
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Run different macros simultaneously.

    Hi,

    I'm spending to much time to solve this question, but i don't fina a solution.

    Anyone can help me, please.

  7. #7
    Forum Guru TMShucks's Avatar
    Join Date
    07-15-2010
    Location
    Manchester, England
    MS-Off Ver
    MSO 2003 & 2007
    Posts
    6,222

    Re: Run different macros simultaneously.

    I think we'd need to see what your macros do to understand how the second can start before the first has finished. In theory, the example described earlier will (can only) execute the macros sequentially. It is, therefore, hard to understand why that is not the case for you.

    Please post the code and/or a sample workbook (with the code).

    Regards

  8. #8
    Registered User
    Join Date
    09-19-2011
    Location
    Porto, Portugal
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Run different macros simultaneously.

    My Macro Actualizar takes too long.
    When the third macro start, the first one is not conclude.
    I solve this question run each one individually.

    My Code

    Macro Actualiza

    Sub Actualizar()
    ActiveWorkbook.RefreshAll
    End Sub

    Macro Botão9_Click
    Sub Botão9_Click()
    Sheets("ANÁLISE").Select
    Range("B1:S74").Select
    Range("B2").Activate
    ActiveWorkbook.RefreshAll
    End Sub

    Macro Configurar
    Sub Configurar()
    Sheets("DETALHE").Select
    Cells.Replace What:="JOÃO ROLDÃO", Replacement:="JOAO ROLDAO", LookAt:= _
    xlWhole, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
    ReplaceFormat:=False
    Sheets("ANÁLISE").Select
    Sheets("VENDAS CL").Visible = True
    Sheets("VENDAS CL").Select
    Range("A44").Select
    Cells.Replace What:="ELETTROCANALLI", Replacement:="ELETTROCANALI", LookAt _
    :=xlWhole, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False _
    , ReplaceFormat:=False
    Cells.Replace What:="ITW", Replacement:="ITW(ELEMATIC)", LookAt:=xlWhole _
    , SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
    ReplaceFormat:=False
    Cells.Replace What:="TARGETTI", Replacement:="TARGETTI(ESEDRA)", LookAt:= _
    xlWhole, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
    ReplaceFormat:=False
    Range("A48").Select
    Selection.ClearContents
    Range("A47").Select
    Selection.ClearContents
    Range("A45").Select
    Selection.ClearContents
    Range("A47").Select
    ActiveCell.FormulaR1C1 = "CABOS ESPECIAIS"
    Range("A48").Select
    Sheets("VENDAS CL").Select
    ActiveWindow.SelectedSheets.Visible = False
    Sheets("ANÁLISE").Select
    Range("A1:A2").Select


    End Sub

  9. #9
    Forum Guru TMShucks's Avatar
    Join Date
    07-15-2010
    Location
    Manchester, England
    MS-Off Ver
    MSO 2003 & 2007
    Posts
    6,222

    Re: Run different macros simultaneously.

    Now I have to ask you to follow the forum rules and add Code Tags to your code examples.

    Can you also clarify if you have followed the original guidance and indicate what macro you use to call the others and what order they are called.

    Thanks

  10. #10
    Forum Guru, retired Admin royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    25,637

    Re: Run different macros simultaneously.

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    Hope that helps.

    RoyUK
    --------
    If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need

    For Excel Tips & Solutions, free examples and tutorials why not check out my downloads

    New members please read & follow the Forum Rules

    Remember to mark your questions Solved and rate the answer(s)

  11. #11
    Registered User
    Join Date
    09-19-2011
    Location
    Porto, Portugal
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Run different macros simultaneously.

    Hi,

    If you don't mind, i attach my file.

    I'm a beginner with macros, and should have a big mistake!!

    In the code, when the first macro is finish it should call the second and at the end of the second macro should call the third macro.

    But the first one take some time, because it is a update in our intranet.

    Regards
    Attached Files Attached Files

  12. #12
    Forum Moderator arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    4,371

    Re: Run different macros simultaneously.

    I am not seeing the command to call the 2nd macro in your first macro.

  13. #13
    Registered User
    Join Date
    09-19-2011
    Location
    Porto, Portugal
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Run different macros simultaneously.

    on the first macro (actualizar) i put a code Call to call de 2nd macro (Botão9_Click).

    I think it's right, isn't it?

  14. #14
    Forum Guru TMShucks's Avatar
    Join Date
    07-15-2010
    Location
    Manchester, England
    MS-Off Ver
    MSO 2003 & 2007
    Posts
    6,222

    Re: Run different macros simultaneously.

    I have asked you to add Code tags to your code sample and, now, so has one of the moderators.

    Unless you repond to the request(s), you will be in breach of the forum rules ... and so will I be if I respond to your post.

    Please follow the rules and we can investigate further.

    Regards

  15. #15
    Registered User
    Join Date
    09-19-2011
    Location
    Porto, Portugal
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Run different macros simultaneously.

    Hope make it right.

    Regards

    Sub Actualizar()
        ActiveWorkbook.RefreshAll
        Call Botão9_Click
    End Sub
    
    Sub Botão9_Click()
        Sheets("ANÁLISE").Select
        Range("B1:S74").Select
        Range("B2").Activate
        ActiveWorkbook.RefreshAll
        Call Configurar
    End Sub
    
    Sub Configurar()
        Sheets("DETALHE").Select
        Cells.Replace What:="JOÃO ROLDÃO", Replacement:="JOAO ROLDAO", LookAt:= _
            xlWhole, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
            ReplaceFormat:=False
        Sheets("ANÁLISE").Select
        Sheets("VENDAS CL").Visible = True
        Sheets("VENDAS CL").Select
        Range("A44").Select
        Cells.Replace What:="ELETTROCANALLI", Replacement:="ELETTROCANALI", LookAt _
            :=xlWhole, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False _
            , ReplaceFormat:=False
        Cells.Replace What:="ITW", Replacement:="ITW(ELEMATIC)", LookAt:=xlWhole _
            , SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
            ReplaceFormat:=False
        Cells.Replace What:="TARGETTI", Replacement:="TARGETTI(ESEDRA)", LookAt:= _
            xlWhole, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
            ReplaceFormat:=False
        Range("A48").Select
        Selection.ClearContents
        Range("A47").Select
        Selection.ClearContents
        Range("A45").Select
        Selection.ClearContents
        Range("A47").Select
        ActiveCell.FormulaR1C1 = "CABOS ESPECIAIS"
        Range("A48").Select
        Sheets("VENDAS CL").Select
        ActiveWindow.SelectedSheets.Visible = False
        Sheets("ANÁLISE").Select
        Range("A1:A2").Select
        
    
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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

Search Engine Friendly URLs by vBSEO 3.2.0