M
Michael
Hi,
I have this piece of VBA code. I want to write new solutions only as I
am running the solver 50 times for example. See explanations in the
code with questions (each solution is an array of values not single
value):
Dim rng As Range
Dim cella As Range
Dim cell1 As Range
Dim i As Long
Dim cnt As Long
Dim bDup As Boolean
If Not IsEmpty(Cells(10, 3)) Then
' 1st value of 1st solution array is in cell (10,3)
Set rng = Range(Cells(10, 3), Cells(59, 3).End(xlUp))
' 1st solution array starts in cell(10,3), and the 50th solution array
starts
' at cell(59,3)
For Each cella In rng
i = 0
cnt = 0
bDup = False
For Each cell1 In cella.Resize(10, 10)
'each solution array has 10 values
For Each mac In vehicleModel.Macros
solutionArray(i) = mac.Value
' How do you define solutionArray as an array?
If cell1.Value = solutionArray(i) Then
cnt = cnt + 1
End If
Next mac
i = i + 1
Next
If cnt = 10 Then
bDup = True
Exit For
End If
Next
End If
If Not bDup Then
' write array
Help to make this VBA code work would be greatly appreciated.
Mike
I have this piece of VBA code. I want to write new solutions only as I
am running the solver 50 times for example. See explanations in the
code with questions (each solution is an array of values not single
value):
Dim rng As Range
Dim cella As Range
Dim cell1 As Range
Dim i As Long
Dim cnt As Long
Dim bDup As Boolean
If Not IsEmpty(Cells(10, 3)) Then
' 1st value of 1st solution array is in cell (10,3)
Set rng = Range(Cells(10, 3), Cells(59, 3).End(xlUp))
' 1st solution array starts in cell(10,3), and the 50th solution array
starts
' at cell(59,3)
For Each cella In rng
i = 0
cnt = 0
bDup = False
For Each cell1 In cella.Resize(10, 10)
'each solution array has 10 values
For Each mac In vehicleModel.Macros
solutionArray(i) = mac.Value
' How do you define solutionArray as an array?
If cell1.Value = solutionArray(i) Then
cnt = cnt + 1
End If
Next mac
i = i + 1
Next
If cnt = 10 Then
bDup = True
Exit For
End If
Next
End If
If Not bDup Then
' write array
Help to make this VBA code work would be greatly appreciated.
Mike