LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
JCL JCL is offline
external usenet poster
 
Posts: 1
Default Macro loops and solver (VBA)


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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro Help - Loops Alan P Excel Programming 4 November 16th 05 10:09 PM
Excel macro/vba loops sammy Excel Programming 1 February 15th 05 05:09 PM
macro that loops till end of worksheet Nadiya Excel Programming 2 November 10th 04 05:36 PM
copying areas and macro loops dynamicsoul Excel Programming 3 September 12th 03 09:43 PM
macro that loops to multiple columns Brad Zenner Excel Programming 1 July 22nd 03 03:17 AM


All times are GMT +1. The time now is 09:51 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"