Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Hello, Today I have taught myself a bit of VBA in order to create a macro I need, but I am having trouble at the final hurdle. I am assuming I have missed something very basic and someone will have solved it in 5 minutes! I need to use Solver, but have a whole column of data to use Solver on, so am trying to create a loop function to apply the solver function to each row in turn. I can get the macro to work for a single row, but trying to get teh loop working is driving me insane! ![]() Below is what I've put together. Set to just one row atm to get it working (which it doesn't!). When I have the specific cell refs in it works for the one row, but obviously not for more than that. So I have tried to use relative referencing, and I think this might be where its going wrong... Any help very gratefully received! Sub Macro1() ' ' Macro1 Macro ' Macro recorded 24/05/2006 by JCL ' ' For Counter = 101 To 101 Set curCell = Worksheets("Emission Factors").Cells(Counter, 14) 'SolverReset SolverOk SetCell:=curCell, MaxMinVal:=2, ValueOf:="0", ByChange:=curCell.Offset(0, 1) SolverAdd CellRef:=curCell.Offset(0, 4), Relation:=2, FormulaText:= _ "'[Reverse DMRB v2.xls]Input Page'!$C$13" SolverOk SetCell:=curCell, MaxMinVal:=2, ValueOf:="0", ByChange:=curCell.Offset(0, 1) SolverOptions MaxTime:=100, Iterations:=100, Precision:=0.000001, AssumeLinear _ :=False, StepThru:=False, Estimates:=1, Derivatives:=1, SearchOption:=1, _ IntTolerance:=5, Scaling:=False, Convergence:=0.0001, AssumeNonNeg:=True SolverOk SetCell:=curCell, MaxMinVal:=2, ValueOf:="0", ByChange:=curCell.Offset(0, 1) SolverSolve UserFinish:=False Next Counter End Sub -- JCL ------------------------------------------------------------------------ JCL's Profile: http://www.excelforum.com/member.php...o&userid=34748 View this thread: http://www.excelforum.com/showthread...hreadid=545090 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Macro Help - Loops | Excel Programming | |||
Excel macro/vba loops | Excel Programming | |||
macro that loops till end of worksheet | Excel Programming | |||
copying areas and macro loops | Excel Programming | |||
macro that loops to multiple columns | Excel Programming |