Lookup Function
I received an email from Clark regarding a formula about a foot long including a VLOOKUP and 3 nested IFs.Fixing the basic formula was easy; then I suggested a Custom Function to replace typing that whole thing. This is the result.
Public Function PriceLookup(PartNum As Variant)
Dim ColLook As Long
Select Case Range("K2")
Case "A", "a"
ColLook = 5
Case "B", "b"
ColLook = 6
Case "C", "c"
ColLook = 7
Case Else
ColLook = 10
End Select
PriceLookup = Application.VLookup(PartNum, [PriceList], ColLook, False)
End Function
See the illustration below for how the function is used.
|