Vlookup with requirements

jessiew84

New Member
Joined
Sep 18, 2014
Messages
5
Hello,

I have searched the web and threads but cannot seem to locate an answer to what I'm trying to achieve.

Is there a way to have Excel narrow the searchable results for a vlookup if other parameters are met first?

I have a long list of pack products that have subproducts under them. I only want Excel to search for subproducts based on the pack that is selected. Further more, I then need Excel to return a part number based on the qty they want to order within that subproduct.

In the example below if the customer were to select Premium Tires and enter in qty 2, I need excel to return the part # AAAAA-2.

I think I want to accomplish this with a vLookup function but I cannot seem to figure out how to incorporate the multiple levels of validation. Your help is greatly appreciate!
Pack ProductSubProductQTYPart #
Premium TiresMulti-tread1AAAAA-1
Premium TiresMulti-tread2AAAAA-2
Premium TiresMulti-tread4AAAAA-3
Standard TiresMulti-tread1CCCCC-1
Standard TiresMulti-tread2CCCCC-2
Standard TiresMulti-tread4CCCCC-3

<TBODY>
</TBODY>
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Code:
=lookif($D$1:$D$7,$A$1:$A$7,$F$2,$B$1:$B$7,$G$2,$C$1:$C$7,$H$2)

Where your data begins in A1 and is the above table.

F2 is your Pack Product
G2 is your SubProduct
H2 is your QTY

Code:
Function lookif(returnRng As Range, prodRng As Range, prod As Range, subRng As Range, subP As Range, _        qtyRng As Range, qty As Range) As Variant




    For Each Cell In prodRng
        If Cell.Value = prod.Value Then
            If subRng(Cell.Row) = subP Then
                If qtyRng(Cell.Row) = qty Then
                    lookif = returnRng(Cell.Row)
                    Exit Function
                End If
            End If
        End If
    Next Cell
    


    lookif = "Not Found"


End Function
 
Upvote 0
It's a user defined function. So you place it in a module or personal workbook and then can call it from the worksheet. I'm not sure of a formula (though there might be one) that is native to excel.
 
Upvote 0
Thank you for your help. I have zero experience with VBA. :-/ I'll see if I can figure this out. Thank you for your help.
 
Upvote 0

Forum statistics

Threads
1,214,665
Messages
6,120,803
Members
448,990
Latest member
rohitsomani

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top