View Single Post
  #3   Report Post  
KLM
 
Posts: n/a
Default

Dana,

Thank you, that did work. GoalSeek does work in this circumstance, but
would I use the same setup if I wanted to use Solver? In other words just
insert the Solver syntax using the same types of variable?

Kris

"Dana DeLouis" wrote:

With no constraints, would Goal Seek work for you? You can usually get a
little more accuracy with Solver though.

Sub DitchDepth()
Dim R As Long 'Row
R = ActiveCell.Row
Do While Cells(R, 1) < ""
Cells(R, 18).GoalSeek Goal:=0, ChangingCell:=Cells(R, 7)
R = R + 1
Loop
End Sub

HTH
--
Dana DeLouis
Win XP & Office 2003


"KLM" wrote in message
...
I am trying to create a macro that will run the Excel Solver on several
rows
in a spreadsheet. The number of rows could change, therefore I need to
create a loop that will work until the row or cell in the A column is
empty.
You will see that I inserted the word current for the row location, I'm
not
sure if this is the correct syntax.

I"m new to VBA, so I appreciate any guidance that anyone has.

Thanks,
KLM


Sub ditchdepth()
'
' ditchdepth Macro
' Macro recorded 7/31/2005 by KMANNING
'
' Keyboard Shortcut: Ctrl+k
counter = 0
Do Until Selection.Offset(counter, 0).Value = "<"
'
SolverOk SetCell:="(current,18)", MaxMinVal:=3, ValueOf:="0",
ByChange:="(current,7)"
SolverSolve
counter = counter + 1
Loop
End Sub