Unique list with additional criteria

jasonwdillon

New Member
Joined
Aug 12, 2015
Messages
6
Hello,

Been searching high and low for an answer to my question with little luck (hoping i didn't blindly miss it).

I have a set of data which changes each week and need to extract a unique list from it, i currently have a formula which works for me, but i now need to adapt it to include additional criteria.

Current formula: {=IFERROR(INDEX($L$3:$L$77, MATCH(0,IF(ISBLANK($L$3:$L$77),1,COUNTIF($P$3:P3, $L$3:$L$77)), 0)),"")}

I need to include the condition that the cell in column I is blank.

So basically the unique list will NOT include any entries from L if the associated cell in I is NOT blank.

A friend helped me construct the above formula, i have some excel knowledge and vaguely know functions which would work, but everywhere i seem to apply them in the formula fails to do as i hoped.
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
jasonwdillon,

Welcome to the MrExcel forum.

1. What version of Excel, and, Windows are you using?

2. Are you using a PC or a Mac?

To start off, and, so that we can get it right on the first try:

Can you post a screenshot of the actual raw data worksheet?

And, can you post a screenshot of the worksheet results (manually formatted by you) that you are looking for?

To post a small screen shot (NOT a graphic, or, picture, or, PNG file, or, flat text) try one of the following:

MrExcel HTML Maker
If you do not know how to install and how to use HTML Mr.Excel Maker
https://www.youtube.com/watch?v=JycvgGppxt0&feature=youtu.be

Excel Jeanie
Download

Borders-Copy-Paste
http://www.mrexcel.com/forum/about-board/444901-how-create-table-like-aladin.html#post2198045

To test the above:
Test Here


The following is a free site:

Or, you can upload your workbook to (the BLUE link-->) Box Net ,
sensitive data changed
mark the workbook for sharing
and provide us with a link to your workbook.
 
Upvote 0
Ideally on the same sheet (currently the list is in column P), however the location where the list comes out isn't too important so long as i can see it
 
Upvote 0
Excel 2013

Windows 7

PC

Sample of data:
BCDEFGHIJKL
20
4021004/08/2015206/08/201550A1
2140310Bed & Breakfast04/08/2015105/08/2015A2
2240420Bed & Breakfast04/08/2015307/08/2015XXXA3
2340520Bed & Breakfast04/08/2015307/08/2015XXXA3
2440610Bed & Breakfast04/08/2015206/08/201551A4
2540710Conference Direct 02/08/2015305/08/2015XXX52
2640810Bed & Breakfast03/08/2015407/08/201558A5
2740910Conference Direct 02/08/2015305/08/2015YYY54
284101003/08/2015306/08/201553A6
294111004/08/2015206/08/201553A6
3041210Bed & Breakfast03/08/2015205/08/201559A1
3141310Conference Direct 19/07/20152008/08/2015ZZZ
3241410Conference Direct 02/08/2015608/08/2015ZZZ
3341510Conference Direct 19/07/20152008/08/2015ZZZ

<tbody>
</tbody>


Expected result:
P
A1
A2
A4
A5
A6

<tbody>
</tbody>











Hopefully this will suffice, please let me know if you need any more information.

As i stated above it is not essential that the results appear in Column P, that's just how I have been working at the moment.
 
Upvote 0
Ideally on the same sheet (currently the list is in column P), however the location where the list comes out isn't too important so long as i can see it

Assuming that column L of data houses solely text values and Sheet1 is the sheet where the data is located (Adjust to suit.)

Activate Formulas | Name Manager and define the following dynamic named ranges...

Lrow:
Rich (BB code):

=MATCH(REPT("z",Sheet1!$L:$L)

Lrange:
Rich (BB code):

=Sheet1!$L$3:INDEX(Sheet1!$L:$L,Lrow)

Irange:
Rich (BB code):

=Sheet1!$I$3:INDEX(Sheet1!$I:$I,Lrow)

And finally, Ivec:
Rich (BB code):

=ROW(Lrange)-ROW(INDEX(Lrange,1,1))+1

P1, control+shift+enter, not just enter:
Rich (BB code):

=SUM(IF(FREQUENCY(IF(Lrange<>"",IF(Irange="",
      MATCH(Lrange,Lrange,0))),Ivec),1))

P2, unique list

P3, control+shift+enter, not just enter, and copy down:
Rich (BB code):

=IF(ROWS($P$3:P3)<=$P$1,INDEX(Lrange,SMALL(IF(FREQUENCY(IF(Lrange<>"",
    IF(Irange="",MATCH(Lrange,Lrange,0))),Ivec),Ivec),ROWS($P$3:P3))),"")
 
Upvote 0
jasonwdillon,

Thanks for the screenshot.

Here is a macro solution for you to consider, that will adjust to the varying number of raw data rows in column B. And, that will run in the active worksheet, with the raw data beginning in cell B20, and, the results will be written to column P, beginning in cell P20.

If the raw data worksheet name is always the same, then I can adjust the macro.

Sample raw data, and, results:


Excel 2007
BCDEFGHIJKLMNOP
19
20402104/8/201526/8/201550A1A1
2140310Bed & Breakfast4/8/201515/8/2015A2A2
2240420Bed & Breakfast4/8/201537/8/2015XXXA3A4
2340520Bed & Breakfast4/8/201537/8/2015XXXA3A5
2440610Bed & Breakfast4/8/201526/8/201551A4A6
2540710Conference Direct2/8/201535/8/2015XXX52
2640810Bed & Breakfast3/8/201547/8/201558A5
2740910Conference Direct2/8/201535/8/2015YYY54
28410103/8/201536/8/201553A6
29411104/8/201526/8/201553A6
3041210Bed & Breakfast3/8/201525/8/201559A1
3141310Conference Direct19/07/2015208/8/2015ZZZ
3241410Conference Direct2/8/201568/8/2015ZZZ
3341510Conference Direct19/07/2015208/8/2015ZZZ
34
Sheet1


Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).

1. Copy the below code
2. Open your NEW workbook
3. Press the keys ALT + F11 to open the Visual Basic Editor
4. Press the keys ALT + I to activate the Insert menu
5. Press M to insert a Standard Module
6. Where the cursor is flashing, paste the code
7. Press the keys ALT + Q to exit the Editor, and return to Excel
8. To run the macro from Excel press ALT + F8 to display the Run Macro Dialog. Double Click the macro's name to Run it.

Code:
Sub jasonwdillon()
' hiker95, 08/12/2015, ME875071
Application.ScreenUpdating = False
Dim rng As Range, c As Range, p, lrb As Long
lrb = Cells(Rows.Count, "B").End(xlUp).Row
Set rng = Range("I20:I" & lrb)
With CreateObject("Scripting.Dictionary")
  For Each c In rng
    If c = vbEmpty Then
      If Not .Exists(c.Offset(, 3).Value) Then
        .Add c.Offset(, 3).Value, c.Offset(, 3).Value
      End If
    End If
  Next
  p = Application.Transpose(Array(.Keys))
End With
If lrb > 19 Then Range("P20:P" & lrb).ClearContents
Range("P20").Resize(UBound(p)) = p
Application.ScreenUpdating = True
End Sub

Before you use the macro with Excel 2007 or newer, save your workbook, Save As, a macro enabled workbook with the file extension .xlsm, and, answer the "do you want to enable macros" question as "yes" or "OK" (depending on the button label for your version of Excel) the next time you open your workbook.

Then run the jasonwdillon macro.
 
Last edited:
Upvote 0
Sorry if this is me being dense,

Is this missing an end? It wont let me save the function to a name without completing the MATCH funct

=MATCH(REPT("z",Sheet1!$L:$L)
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,552
Members
449,088
Latest member
davidcom

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