How to use Solveradd for step parameter?

alee001

Board Regular
Joined
Sep 9, 2014
Messages
154
Office Version
  1. 2010
Platform
  1. Windows
I want to VBA Solver search parameter array like as 5, 8, 11, 14, 17...60 step 3, I use SolverAdd code as follow but not work?Why
[W4] as parameter start 5
Range("step") = 3
Code:
SolverAdd CellRef:=[W4], Relation:=2, FormulaText:=2+Range("step")*Int([W4]/Range("step"))
 
Last edited:

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Improve code:
[W4] as change parameter
Range("p1") as start parameter (i.e. 5)
[
Code:
SolverAdd CellRef:=[W4], Relation:=2, FormulaText:=Range("p1") Mod Range("step")+Range("step")*Int([W4]/Range("step"))
 
Upvote 0
I also tried follow code but not work too?
Code:
SolverAdd CellRef:=[W4] Mod Range("step"), Relation:=2, FormulaText:=Range("p1") Mod Range("step")
 
Upvote 0
I don't think FormulaText can actually include a formula. It can be a value, a cell address, or the name of a named cell.
 
Upvote 0
After constant testing, the following code can control Solver searching by step parameter.
[W4] as change cell
[A1] as start parameter
[A2] as step no.
[W5] =IF(AND(A1-INT(A1)=0,A1>1),IF(MOD(W4,A2)=MOD(A1,A2),1,0),IF(MOD(W4*100,A2*100)=MOD(A1*100,A2*100),1,0))
Code:
SolverAdd CellRef:=[W5], Relation:=2, FormulaText:=1
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,187
Members
452,616
Latest member
intern444

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top