View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Michael[_27_] Michael[_27_] is offline
external usenet poster
 
Posts: 41
Default Writing Unique Solutions; what could be wrong here?

Hi Everyne,

Below is the code piece I am using although it is not working yet! Allow
me please to state the followings:

1)A solution has 8 components (from 0 to 7),
2)1st solution starts at C10 (i.e. cells(10,3)), and end
at J10,
3)The model is assumed to run 50 times


Dim rng As Range
Dim cella As Range
Dim cell1 As Range
Dim i As Long
Dim solutionArray(0 To 7) As Variant
Dim cnt As Long
Dim bDup As Boolean

Cline = 1
For JobNr = 1 To 50 'run the model 50 times
vehicleModel.Solve
i = 0
For Each mac In vehicleModel.Macros
solutionArray(i) = mac.Value 'For each run, write its solution into an array
i = i + 1
Next

If Not IsEmpty(Cells(10, 3)) Then
Set rng = Range(Cells(10, 3), Cells(60, 3).End(xlUp))
' Cells (10,3) is where 1st component
' of 1st solution is written

For Each cella In rng
i = 0
cnt = 0
bDup = False

For Each cell1 In cella.Resize(1, 8)
If cell1.Value = solutionArray(i) Then

cnt = cnt + 1

End If

i = i + 1
Next
If cnt = 8 Then
bDup = True
Exit For
End If
Next
End If
If Not bDup Then

' write solution array
NEXT

What is missing here to make this code piece work?

Thanks,
Mike