Return All the Different Results

south0085

Board Regular
Joined
Aug 15, 2011
Messages
141
The title of this question was poorly written. I apologize.

I have a column with part numbers in it. Column I. It has the same 120 or so part numbers repeaded over and over and over again.

I have another column (Column J) with prices in it. Many of these prices for each part are the same, but some are different. Example:

from tmmc

I
J
4999
87940-0R190-C0
43.0835
5000
87910-0R210-B1
38.8914
5001
87940-0R190-C0
15.5287
5002
87940-0R190-C0
25.0341
5003
87910-0R190-D1
83.3021

<tbody>
</tbody>


I want to find out all the different prices there are for each part. For example, 87940-0R190-C0 has three different part numbers. So the returned value would be 3. Kind of like a count, I guess.

Thank you for your help.

<tbody>
</tbody>
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
This macro will place the unique part number names in column L and the number of occurrences for each in column M.
Code:
Sub Test()
    Dim LastRow As Long
    LastRow = Sheets("Sheet1").Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    Dim rng As Range
    Sheets("Sheet1").Range("I1:I" & LastRow).AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:=Range("I1:I" & LastRow), Unique:=True
    Set rnguniques = Sheets("Sheet1").Range("I2:I" & LastRow).SpecialCells(xlCellTypeVisible)
    If Sheets("Sheet1").FilterMode Then Sheets("Sheet1").ShowAllData
    For Each rng In rnguniques
        Cells(Rows.Count, "L").End(xlUp).Offset(1, 0) = rng
        Cells(Rows.Count, "M").End(xlUp).Offset(1, 0) = WorksheetFunction.CountIf(Range("I:I"), rng)
    Next rng
End Sub
It assumes you have headers in row 1.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,523
Messages
6,125,317
Members
449,218
Latest member
Excel Master

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