I have a spreadsheet of prices from a selection of suppliers, with one supplier per column.
// Conditional Format code
=D2=MIN($D2:$K2)
I have used conditional formatting to highlight the cheapest value (black). Then, I use Macro/Basic code to filter and export based on the highlighted colour to make order lists for each supplier. Everything works fine so far.
In the image, two suppliers are highlighted on the same row at £0.17. When I run my code to export the highlighted lines, it will include it in both supplier orders. I only want one highlighted value to add to a single supplier's order.
The problem is that when values for the same product are equal, both (or more) suppliers are highlighted. This results in duplicate orders being exported. I want a way to tie-break these duplicate values, so only one value is highlighted, according to a preference order (Supplier A, then B, C, D, etc.).
This is the code I currently use. It filters down the suppliers and is run each time with AutoFilter Field= changed for each supplier column:
ActiveSheet.Range("$A$1:$P$1219").AutoFilter Field:=4, Criteria1:=RGB(0, 0 _
, 0), Operator:=xlFilterCellColor
ActiveSheet.Range("$A$1:$S$1219").AutoFilter Field:=18, Criteria1:="<>0", Operator:=xlFilterValues
'
'Product&Pack / Price / Quantity''
Range("A2:B25,C2:C25,R2:R25").Select
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Copy
Sheets("Branch1").Select
Range("A2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
''Reset Filters''
Sheets("NEW2025").Select
ActiveSheet.ShowAllData
I have tried a few solutions I found via Google, such as adding a very small difference to each column value (e.g., dividing by 0.0001) to create a tie-breaker, but I couldn't get it to work properly.
If somebody could help, or even point me in the right direction, that would be greatly appreciated.
Thanks in advance.
