View Full Version : Multiple Macros for one Workbook/sheet

01-20-2010, 11:11 PM

I have different macros running in one workbook. I have no idea if seperate macros can be in a worksheet/workbook running simultaniously. I now have combined 2 macros into one, the one macro runs after the other one and actually have no idea if it might be better to seperate them. In my case the macros concerning both involve an automated solver solution if cetain conditions are met. Now macro no two runs after the first one is completed. All toghether it takes about 5 to 10 seconds to complete.

What would be the best way to set macro's up in a workbook?



Simon Lloyd
01-20-2010, 11:41 PM
willemeulen, it's not whether you can run a single macro or two seperate ones but how they are constructed, we would need to see the code and possible a sample workbook in order to give you a workable answer :)

01-20-2010, 11:50 PM
Sub CalculateDepth()
ActiveCell.FormulaR1C1 = "0.001"
SolverOk SetCell:="$T$56", MaxMinVal:=3, ValueOf:=Range("Q56").Value, ByChange:="$R$56"
SolverSolve True

ActiveCell.FormulaR1C1 = "0.001"
SolverOk SetCell:="$T$64", MaxMinVal:=3, ValueOf:=Range("Q64").Value, ByChange:="$R$64"
SolverSolve True

End Sub

Jan Karel Pieterse
01-21-2010, 12:58 AM
Nothing wrong with your code.
You can have any number of macros in a workbook, each in their own Sub. You can also have multiple subs in a module and also multiple modules.
But you always run subs one after the other. VBA cannot run multiple macros simultaneously.