Hi
I have a problem.
Please see attached spreadsheet.
What I want to do is not that complicated, but I am simply stucked.
- if value in (col A) and (col C) are same
- then (col F) = (col B)*(col E) + (col B)
I want to run a solver in a loop so that
- the macro finds each value of (col C) matching (col A)
- if matching, the solver sets value in (col E) so that (col F) = 100
- otherwise, leaves cell in col E blank
so far, my code is like that and does not work
I just feel stupid not beeing able to do this by myselfSub Button()
Dim r As Range
Dim c As Range
Dim f As Range
Dim p As Range
Set r = Range("A2", Range("A65536").End(xlUp))
Set f = Range("C2", Range("C65536").End(xlUp))
For Each c In r.Cells
For Each p In f.Cells
If p = c Then
SolverOk SetCell:=p.Offset(0, 3), MaxMinVal:=3, ValueOf:=100, bychange:=p.Offset(0, 2).Address
SolverSolve True
SolverFinish KeepFinal:=1
End If
Next p
Next c
End Sub
I hope I am clear enough
Thanks a lot in advance for your help.
Bookmarks