Well, yes ... but, actually, you could have just edited the Post #8 ;-)
Regards
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
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)
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
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks