Finding a list of data in a price list and returning the results

eqbal

Board Regular
Joined
Sep 6, 2002
Messages
92
Hi,
I have a price list containing over 10000 items with descriptions, catalogue no, unit and etc. spreading from column A to D. Now I have received an inquiry for 300 items and it's a headache to search for each item through my price list and copy every detail. Also, while there might be several occurrences of one item (for example different compounds of one material or different packaging) and i want all occurrences to be offered to the customer, so that they can make a well informed decision, I can not use VLOOKUP function, while it only returns the first item it finds.

So basically I need a code to look for items listed in a specific column (say F) in my price list (columns A to D) and when it finds the item (or multiple items), it returns all the information listed in columns A to D relating to the item, in a new table, say in Sheet 2. The code must search column B for the data listed in column F. It would be helpful to have the row no. of each found item too.

Thanks in advance
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Hi Eqbal,

Try the sample below in a standard module.

Words or phrases to find in column B placed in column F

Code:
Public Sub Find_Copy()

Dim oSearch As Range
Dim oCell As Range
Dim oFind As Range
Dim oFound As Range
Dim oOutCell As Range

Dim oActive As Worksheet
Dim oOutSheet As Worksheet

Dim sFirstFind As String

Set oActive = ActiveSheet
Set oOutSheet = ThisWorkbook.Worksheets.Add
Set oOutCell = oOutSheet.Range("A2")

oActive.Activate

Set oFind = oActive.Range("F1:F" & oActive.Range("F" & Rows.Count).End(xlUp).Row)


Set oSearch = oActive.Range("B:B")

For Each oCell In oFind
    Set oFound = oSearch.Find(what:=oCell.Text, LookIn:=xlValues, lookat:=xlPart, MatchCase:=False)
    If Not oFound Is Nothing Then
        sFirstFind = oFound.Address
        Do
            
            oOutCell.Value = oActive.Range("A" & oFound.Row)
            oOutCell.Offset(0, 1).Value = oActive.Range("B" & oFound.Row)
            oOutCell.Offset(0, 2).Value = oActive.Range("C" & oFound.Row)
            oOutCell.Offset(0, 3).Value = oActive.Range("D" & oFound.Row)
            oOutCell.Offset(0, 4).Value = oFound.Row
           
            Set oOutCell = oOutCell.Offset(1, 0)
            Set oFound = oSearch.FindNext(oFound)
            
        Loop While Not oFound Is Nothing And oFound.Address <> sFirstFind
    End If
Next oCell

oOutSheet.Columns.AutoFit

End Sub
 
Upvote 0

Forum statistics

Threads
1,213,536
Messages
6,114,215
Members
448,554
Latest member
Gleisner2

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