LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default VBA code question?!

Hi everyone,

I have this simple 3 subs vba code. It runs 8 times and each solution
has 24 values that is put in one column of 24 raws. So, the 1st
solution found gets written at N2 to N25....and so on.

The problem I have is this: The 1st solution that gets written from
N2-N25, later it gets removed; just the 1st solution! What could be
causing this in the code? Thanks in advance.

Option Explicit
Option Base 1
Sub Pareto()
Dim cell As Range, ModelCounter As Integer, JobNr As Integer
Dim ret As Integer
Dim ARngSolution As Range

Application.ScreenUpdating = False

ModelCounter = 0
Set ARngSolution = Range("SolDVSens")
ARngSolution.ClearContents

For JobNr = 1 To 8

ret = SolverSolve(UserFinish:=True)

If ret = 0 Or ret = 14 Then
ModelCounter = ModelCounter + 1
RunSolver
StoreResults ModelCounter
End If
Next
End Sub


Sub RunSolver()
SolverReset
SolverOk SetCell:=Range("Obj2"), MaxMinVal:=1,
ByChange:=Range("Picked")
SolverAdd CellRef:=Range("Spending"), Relation:=1,
FormulaText:="Budget"
SolverAdd CellRef:=Range("Picked"), Relation:=5
SolverOptions AssumeLinear:=True, AssumeNonNeg:=True
End Sub

Sub StoreResults(ModelCounter As Integer)
Dim i As Integer
With Range("N1")
For i = 1 To 24
.Offset(i, ModelCounter) = Range("Picked").Cells(i)
Next
End With
End Sub

 
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
VBA code question Damian Excel Discussion (Misc queries) 1 September 25th 09 09:54 PM
VBA code question JEV Excel Discussion (Misc queries) 2 March 1st 07 06:02 PM
Code Question Ronbo Excel Programming 3 September 23rd 05 09:33 PM
Code Question Michael168[_111_] Excel Programming 9 September 17th 04 06:31 AM
VBA CODE Question Gary[_5_] Excel Programming 2 July 29th 03 03:45 AM


All times are GMT +1. The time now is 12:09 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"