PDA

View Full Version : Opening all worksheets in a workbook



haddy27
04-25-2007, 07:36 AM
Think this will be an easy one for those "in the know".

I am looking to run a solver function in each and every worksheet in a workbook.

The code I have so far, that is coming up with a run time error is:


Dim MyWorkbook As Object
Dim Wks As Object
Set MyWorkbook = ActiveWorkbook
For Each Wks In MyWorkbook
AutoAcceptWorkbookopen
SolverOk SetCell:="$I$13", MaxMinVal:=3, ValueOf:="0", ByChange:="$I$6"
SolverSolve
ActiveWorkbook.Save

Next Wks

End Sub


I'm assuming I'm missing something out, can anybody help?

haddy27

Ken Puls
04-25-2007, 08:59 AM
For Each Wks In MyWorkbook.worksheets