+ Reply to Thread
Page 2 of 2 FirstFirst 12
Results 16 to 19 of 19

Thread: Run different macros simultaneously.

  1. #16
    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.

    Well, yes ... but, actually, you could have just edited the Post #8 ;-)

    Regards

  2. #17
    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.

    OK, basically, you have three macros:

    Actualizar
    Botão9_Click
    Configurar

    The macro button calls the Actualizar macro. This does a RefreshAll and calls the Botão9_Click macro. This does some "selecting", *another* RefreshAll and then calls the Configurar macro.

    In theory, that would have the same effect as having a Main module as I described earlier if you removed the embedded calls to subsequent macros.

    I think the problem is that a) you execute RefreshAll twice and b) the links are updated in the background. I'm guessing that's why it's taking a while to complete.

    I would recommend removing one of the RefreshAll commands.


    It was a little confusing that you had each of your macros in a separate module. For my benefit, I cut/pasted them all into one module so I could better see the flow.

    I've also tidied up a bit and added ScreenUpdating at the beginning and end of each module. That should make it run smoother.

    Sub Actualizar()
    Application.ScreenUpdating = False
        Debug.Print "Actualizar"
        ActiveWorkbook.RefreshAll
        Botão9_Click
    Application.ScreenUpdating = True
    End Sub
    
    Sub Botão9_Click()
    Application.ScreenUpdating = False
        Debug.Print "Botão9_Click"
        Sheets("ANÁLISE").Select
        Range("B1:S74").Select
        Range("B2").Activate
        ActiveWorkbook.RefreshAll ' <<< probably need to remove this line
        Configurar
    Application.ScreenUpdating = True
    End Sub
    
    Sub Configurar()
    Application.ScreenUpdating = False
        Debug.Print "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").ClearContents
        Range("A45").ClearContents
        Range("A47").FormulaR1C1 = "CABOS ESPECIAIS"
        Range("A48").Select
        Sheets("VENDAS CL").Visible = False
        Sheets("ANÁLISE").Select
        Range("A1:A2").Select
    Application.ScreenUpdating = True
    End Sub

    Regards

  3. #18
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    MS 2007
    Posts
    5,372

    Re: Run different macros simultaneously.

    Okay, I see what the problem is. Your first macro actually completes very quickly, it tells Excel to Refresh the workbook. Then it moves on to the second macro but meanwhile Excel is busy refreshing all its calculations.
    ChemistB
    My 2¢

    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

  4. #19
    Forum Guru martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    10,789

    Re: Run different macros simultaneously.

    maybe making it wait 5 seconds or so would help
    Application.Wait Time + TimeSerial(0, 0, 5)
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and a dabbler in Cisco
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

+ 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