View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default VBA to write Unique Solutions ONLY?

Mike,

Here is some code to tidy up afterwards

Dim cLastRow As Long

cLastRow = Cells(Rows.Count, "B").End(xlUp).Row
Range("C2").EntireColumn.Insert
Range("C1").Value = "Temp"
Range("C2").FormulaR1C1 = "=COUNTIF(R2C2:RC[-1],RC[-1])"
Range("C2").AutoFill Destination:=Range("C2:C" & cLastRow),
Type:=xlFillDefault
Columns("C:C").AutoFilter Field:=1, Criteria1:="1"
Range("C2:C" &
cLastRow).SpecialCells(xlCellTypeVisible).EntireRo w.Delete
Columns("C:C").EntireColumn.Delete


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Michael" wrote in message
om...
Hi everyone,

I run an optimizer n times, say 10, and tell the model to write
feasible solutions into an excel table as follows:

RUN Cost Weight Volume
1 2.3 51.27 20.3
2 3.1 49.2 22.2
3 4.3 37.2 16.7
4 2.3 51.27 20.3
5
6
and so on. As you see solutions 1 and 4 are duplicate which I don't
want. How can I write a piece of VBA code to prevent this? In other
words, the table should like this:

RUN Cost Weight Volume
1 2.3 51.27 20.3
2 3.1 49.2 22.2
3 4.3 37.2 16.7
4

and so on.

Regards,
Mike