Hello
How to repeat a code for selected sheets (or a contiguous range of sheets)
in a Workbook?
The code is:
Range("J16").Select
SolverOk SetCell:="$J$16", MaxMinVal:=1, ValueOf:="0",
ByChange:="$F$4:$I$12"
SolverSolve UserFinish:=True
Hello
How to repeat a code for selected sheets (or a contiguous range of sheets)
in a Workbook?
The code is:
Range("J16").Select
SolverOk SetCell:="$J$16", MaxMinVal:=1, ValueOf:="0",
ByChange:="$F$4:$I$12"
SolverSolve UserFinish:=True
For each ws in ActiveWorkbook.Sheets
ws.Range("J16").Select
SolverOk SetCell:="$J$16", MaxMinVal:=1, ValueOf:="0",
ByChange:="$F$4:$I$12"
SolverSolve UserFinish:=True
Next
"Dmitry" wrote:
> Hello
> How to repeat a code for selected sheets (or a contiguous range of sheets)
> in a Workbook?
> The code is:
> Range("J16").Select
> SolverOk SetCell:="$J$16", MaxMinVal:=1, ValueOf:="0",
> ByChange:="$F$4:$I$12"
> SolverSolve UserFinish:=True
>
>
>
Thanks Viquar for replying.
Does "For each ws in ActiveWorkbook.Sheets" repeats for all worksheets? I
wrote "How to repeat a code for selected sheets (or a contiguous range of
sheets) in a Workbook?", not all worksheets.
"Viquar" <[email protected]> сообщил/сообщила в новостях
следующее: news:[email protected]...
> For each ws in ActiveWorkbook.Sheets
> ws.Range("J16").Select
> SolverOk SetCell:="$J$16", MaxMinVal:=1, ValueOf:="0",
> ByChange:="$F$4:$I$12"
> SolverSolve UserFinish:=True
>
> Next
>
> "Dmitry" wrote:
>
> > Hello
> > How to repeat a code for selected sheets (or a contiguous range of
sheets)
> > in a Workbook?
> > The code is:
> > Range("J16").Select
> > SolverOk SetCell:="$J$16", MaxMinVal:=1, ValueOf:="0",
> > ByChange:="$F$4:$I$12"
> > SolverSolve UserFinish:=True
> >
> >
> >
Hi Dmitry,
Try something like:
'=============>>
Public Sub Tester()
Dim SH As Worksheet
For Each SH In ActiveWindow.SelectedSheets
With SH
Application.Goto .Range("J16")
'Your Solver code
End With
Next SH
End Sub
'<<=============
---
Regards,
Norman
"Dmitry" <[email protected]> wrote in message
news:%[email protected]...
> Hello
> How to repeat a code for selected sheets (or a contiguous range of sheets)
> in a Workbook?
> The code is:
> Range("J16").Select
> SolverOk SetCell:="$J$16", MaxMinVal:=1, ValueOf:="0",
> ByChange:="$F$4:$I$12"
> SolverSolve UserFinish:=True
>
>
Maybe...
For each ws in ActiveWindow.selectedSheets
Dmitry wrote:
>
> Thanks Viquar for replying.
> Does "For each ws in ActiveWorkbook.Sheets" repeats for all worksheets? I
> wrote "How to repeat a code for selected sheets (or a contiguous range of
> sheets) in a Workbook?", not all worksheets.
> "Viquar" <[email protected]> сообщил/сообщила в новостях
> следующее: news:[email protected]...
> > For each ws in ActiveWorkbook.Sheets
> > ws.Range("J16").Select
> > SolverOk SetCell:="$J$16", MaxMinVal:=1, ValueOf:="0",
> > ByChange:="$F$4:$I$12"
> > SolverSolve UserFinish:=True
> >
> > Next
> >
> > "Dmitry" wrote:
> >
> > > Hello
> > > How to repeat a code for selected sheets (or a contiguous range of
> sheets)
> > > in a Workbook?
> > > The code is:
> > > Range("J16").Select
> > > SolverOk SetCell:="$J$16", MaxMinVal:=1, ValueOf:="0",
> > > ByChange:="$F$4:$I$12"
> > > SolverSolve UserFinish:=True
> > >
> > >
> > >
--
Dave Peterson
Thanks. I will try.
"Dave Peterson" <[email protected]> ???????/???????? ? ????????
?????????: news:[email protected]...
> Maybe...
>
> For each ws in ActiveWindow.selectedSheets
>
> Dmitry wrote:
> >
> > Thanks Viquar for replying.
> > Does "For each ws in ActiveWorkbook.Sheets" repeats for all worksheets?
I
> > wrote "How to repeat a code for selected sheets (or a contiguous range
of
> > sheets) in a Workbook?", not all worksheets.
> > "Viquar" <[email protected]> сообщил/сообщила в новостях
> > следующее: news:[email protected]...
> > > For each ws in ActiveWorkbook.Sheets
> > > ws.Range("J16").Select
> > > SolverOk SetCell:="$J$16", MaxMinVal:=1, ValueOf:="0",
> > > ByChange:="$F$4:$I$12"
> > > SolverSolve UserFinish:=True
> > >
> > > Next
> > >
> > > "Dmitry" wrote:
> > >
> > > > Hello
> > > > How to repeat a code for selected sheets (or a contiguous range of
> > sheets)
> > > > in a Workbook?
> > > > The code is:
> > > > Range("J16").Select
> > > > SolverOk SetCell:="$J$16", MaxMinVal:=1, ValueOf:="0",
> > > > ByChange:="$F$4:$I$12"
> > > > SolverSolve UserFinish:=True
> > > >
> > > >
> > > >
>
> --
>
> Dave Peterson
Thanks. I will try.
"Norman Jones" <[email protected]> сообщил/сообщила в новостях
следующее: news:[email protected]...
> Hi Dmitry,
>
> Try something like:
>
> '=============>>
> Public Sub Tester()
> Dim SH As Worksheet
> For Each SH In ActiveWindow.SelectedSheets
> With SH
> Application.Goto .Range("J16")
> 'Your Solver code
> End With
> Next SH
> End Sub
> '<<=============
>
>
> ---
> Regards,
> Norman
>
>
>
> "Dmitry" <[email protected]> wrote in message
> news:%[email protected]...
> > Hello
> > How to repeat a code for selected sheets (or a contiguous range of
sheets)
> > in a Workbook?
> > The code is:
> > Range("J16").Select
> > SolverOk SetCell:="$J$16", MaxMinVal:=1, ValueOf:="0",
> > ByChange:="$F$4:$I$12"
> > SolverSolve UserFinish:=True
> >
> >
>
>
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks