Try the code below: copy it all into a codemodule, and run TryNow.
HTH,
Bernie
MS Excel MVP
Dim LongLeaderDME As Double
Sub TryNow()
GetData 0.25, 3.475
MsgBox LongLeaderDME
End Sub
Sub GetData(DiaLeader As Double, _
LongLeader As Double)
Dim cel As Range
Dim rng As Range
Set rng = [A1:A2000]
For Each cel In rng
If cel.Value = "Leader pin" Then
If cel.Offset(, 1).Value = DiaLeader Then
If cel.Offset(, 2).Value LongLeader Then
LongLeaderDME = cel.Offset(, 3).Value
Exit For
End If
End If
End If
Next cel
End Sub
"zapatista66 " wrote in message
...
Kind diameter length Price
Leader pin 0.250 3.250 3$
Leader pin 0.250 3.750 4$
Leader pin 0.250 4.250 10$
Leader pin 0.750 4.750 15$
Leader pin 0.750 5.250 5$
Leader pin 0.750 5.750 7$
Socket 1 6.250 5$
Socket 1 6.750 2$
Socket 1 7.250 21$
LongLeaderDME = length
So, I want to look first in kind, after in diameter and to return the
length in the list.
exemple: kind:Leader pin, diameter:0.250, and LongLeader:3.743
The program will return the line 2. Length=3.750 because is the nearest
value (up) for LongLeader. Finally, I can have the price 4$.
Is it possible ?
---
Message posted from http://www.ExcelForum.com/