Hi Leedme,
Shouldn't the result be part D because 100/5 = 20, so it is not below 20?
See how this code works out for you:
Sub RunMe()
Dim lRow, x As Integer
lRow = Range("K" & Rows.Count).End(xlUp).Row
For x = lRow To 2 Step -1
If Range("C2").Value / Range("K" & x).Value >= 20 Then
Range("B2").Value = Range("K" & x).Value
Range("A2").Value = Range("J" & x).Value
Exit Sub
End If
Next x
End Sub
The code will start looking at the bottom of your table. Check if the value in C2 divided by the table value is higher or the same as 20.
If not, then check the value above it.
If so, then copy the table value to B2 and the part number to the left to A2.
Best regards,
Trowa
drastically simplified what I am really trying to do, so then I can see how the macro needs to created to do what is really needed.
I appreciate your help on this!!
I was hoping to have the macro/or formula not care about the math of C2/B2.
Can it just look at E2 and see its below the value of 20, then look in the table and insert the values into B2 until the value in E2 is not below 20?
I will manually be changing the value in C2
The data in E2 is not linked to the table, so when E2 is below 20, then how do we know which data to pull from the table?
When you want to insert values in B2 until the value in E2 is not below 20, then that is what the provided macro does. I added the math C2/B2, so you can change the value in C2 and the macro will still work.
Could you re-explain what you enter manually and what you want to be done automatically?
Best regards,
Trowa
The value in E20 can not go below a set value of 6.
C2, C4, C5 and C6 are entered to satisfy the formulas in the picture.
I would like to have values from Column M automatically placed in A9, until the value in E20 is greater than 6.
When that is satisfied, then I would like which ever value was used from Column M, to insert the corresponding value in its row from Column L, into cell A3.