Note: The other languages of the website are Google-translated. Back to English
Inloggen  \/ 
x
or
x
Registreer  \/ 
x

or

Hoe dynamisch een lijst met unieke waarden extraheren uit een kolombereik in Excel?

Voor een kolombereik waarvan de waarden regelmatig veranderen, moet u altijd alle unieke waarden uit het bereik halen, ongeacht hoe deze is gewijzigd. Hoe maak je een dynamische lijst met unieke waarden? In dit artikel wordt uitgelegd hoe u hiermee om kunt gaan.

Extraheer dynamisch een lijst met unieke waarden uit een kolombereik met formule
Extraheer dynamisch een lijst met unieke waarden uit een kolombereik met VBA-code


Extraheer dynamisch een lijst met unieke waarden uit een kolombereik met formule

Zoals onderstaand screenshot laat zien, moet u dynamisch een lijst met unieke waarden extraheren uit bereik B2: B9. Probeer de volgende matrixformule.

1. Selecteer een lege cel zoals D2, voer de onderstaande formule erin in en druk op Ctrl + Shift + Enter toetsen tegelijk. (B2: B9 zijn de kolomgegevens waarvan u de unieke waarden wilt extraheren, D1 is de cel hierboven waarin uw formule zich bevindt)

=IFERROR(INDEX($B$2:$B$9, MATCH(0,COUNTIF($D$1:D1, $B$2:$B$9), 0)),"")

2. Blijf cel D2 selecteren en sleep vervolgens de vulhendel omlaag om alle unieke waarden uit het opgegeven bereik op te halen.

Nu worden alle unieke waarden in kolombereik B2: B9 geëxtraheerd. Wanneer waarden in dit bereik worden gewijzigd, wordt de lijst met unieke waarden onmiddellijk dynamisch gewijzigd.

Selecteer en markeer eenvoudig alle unieke waarden in een bereik in Excel:

Het Selecteer Dubbele en unieke cellen nut van Kutools for Excel kan u helpen bij het eenvoudig selecteren en markeren van alle unieke waarden (inclusief de eerste duplicaten) of de unieke waarden die slechts één keer voorkomen, evenals dubbele waarden die u nodig heeft, zoals onderstaand screenshot.
Download nu Kutools voor Excel! (Gratis parcours van 30 dagen)


Extraheer dynamisch een lijst met unieke waarden uit een kolombereik met VBA-code

U kunt ook een lijst met unieke waarden dynamisch extraheren uit een kolombereik met de volgende VBA-code.

1. druk op anders + F11 toetsen tegelijkertijd om het Microsoft Visual Basic voor toepassingen venster.

2. In de Microsoft Visual Basic voor toepassingen venster klikt Invoegen > module. Kopieer en plak vervolgens de onderstaande VBA-code in het module venster.

VBA-code: extraheer een lijst met unieke waarden uit een bereik

Sub CreateUniqueList()
Dim xRng As Range
Dim xLastRow As Long
Dim xLastRow2 As Long
Dim I As Integer
On Error Resume Next
Set xRng = Application.InputBox("Please select range:", "Kutools for Excel", Selection.Address, , , , , 8)
If xRng Is Nothing Then Exit Sub
On Error Resume Next
xRng.Copy Range("D2")
xLastRow = xRng.Rows.Count + 1
ActiveSheet.Range("D2:D" & xLastRow).RemoveDuplicates Columns:=1, Header:=xlNo
xLastRow2 = Cells(Rows.Count, "B").End(xlUp).Row
For I = 1 To xLastRow2
  If ActiveSheet.Range("D2:D" & xLastRow2).Cells(I).Value = "" Then
     ActiveSheet.Range("D2:D" & xLastRow2).Cells(I).Delete
  End If
Next
End Sub

Opmerking:: In de code is D2 de cel waarin u de lijst met unieke waarden zult vinden. U kunt het naar behoefte wijzigen.

3. Ga terug naar het werkblad en klik op Invoegen > Vormen > Rechthoek. Zie screenshot:

4. Teken een rechthoek in uw werkblad en typ vervolgens enkele woorden die u erop wilt weergeven. Klik er vervolgens met de rechtermuisknop op en selecteer Wijs macro toe vanuit het rechtsklikmenu. In de Wijs macro toe dialoogvenster, selecteert u het Unieke lijst makenL functie in het Macronaam vak en klik vervolgens op het OK knop. Zie screenshot:

5. Klik nu op de rechthoekknop, een Kutools for Excel dialoogvenster verschijnt, selecteer het bereik dat de unieke waarden bevat die u wilt extraheren en klik vervolgens op het OK knop.

Vanaf nu kunt u de bovenstaande stap 5 herhalen om de unieke waardenlijst automatisch bij te werken.


Gerelateerde artikelen:


De beste tools voor kantoorproductiviteit

Kutools voor Excel lost de meeste van uw problemen op en verhoogt uw productiviteit met 80%

  • visfuik: Snel invoegen complexe formules, grafieken en alles wat je eerder hebt gebruikt; Versleutel cellen met wachtwoord; Maak een mailinglijst en stuur e-mails ...
  • Super Formula-balk (bewerk eenvoudig meerdere regels tekst en formule); Lay-out lezen (gemakkelijk grote aantallen cellen lezen en bewerken); Plakken in gefilterd bereik...
  • Voeg cellen / rijen / kolommen samen zonder gegevens te verliezen; Gespleten cellen inhoud; Combineer dubbele rijen / kolommen... Voorkom dubbele cellen; Vergelijk Ranges...
  • Selecteer Dupliceren of Uniek Rijen; Selecteer lege rijen (alle cellen zijn leeg); Super zoeken en fuzzy zoeken in veel werkboeken; Willekeurige selectie ...
  • Exacte kopie Meerdere cellen zonder de formuleverwijzing te wijzigen; Maak automatisch verwijzingen naar meerdere bladen; Plaats kogels, Selectievakjes en meer ...
  • Extraheer tekst, Tekst toevoegen, Verwijderen op positie, Ruimte verwijderen; Paging-subtotalen maken en afdrukken; Converteren tussen celinhoud en opmerkingen...
  • Super filter (bewaar en pas filterschema's toe op andere bladen); Geavanceerd sorteren per maand / week / dag, frequentie en meer; Speciaal filter door vet, cursief ...
  • Combineer werkmappen en werkbladen; Tabellen samenvoegen op basis van sleutelkolommen; Gegevens splitsen in meerdere bladen; Batch Converteer xls, xlsx en PDF...
  • Meer dan 300 krachtige functies. Ondersteunt Office / Excel 2007-2019 en 365. Ondersteunt alle talen. Eenvoudig te implementeren in uw onderneming of organisatie. Gratis proefperiode van 30 dagen met volledige functies. 60 dagen geld-terug-garantie.
kte tabblad 201905

Office-tabblad Brengt een interface met tabbladen naar Office en maakt uw werk veel gemakkelijker

  • Schakel bewerken en lezen met tabbladen in Word, Excel, PowerPoint in, Publisher, Access, Visio en Project.
  • Open en maak meerdere documenten in nieuwe tabbladen van hetzelfde venster in plaats van in nieuwe vensters.
  • Verhoogt uw productiviteit met 50% en vermindert elke dag honderden muisklikken!
officetab onderkant
Say something here...
symbols left.
You are guest
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    francesco · 9 months ago
    how to make the vba code work for a range where another formula was used?
    on column B I have a formula, referring to columns D and E.
    If I use apply the code to column L (let's say), (obviously, properly modifying the cells in the code) the macro returns the formula applied to columns M and N... It works, then, but not as I want!
    How to keep the values in column B?
    thanks
  • To post as a guest, your comment is unpublished.
    A · 1 years ago
    thank you very much
  • To post as a guest, your comment is unpublished.
    Charlotte · 1 years ago
    I try the VBA Code and the formula. The code VBA is working very well but I can't keep a file with macro. But th problem is that I can't make the formula working. Did anybody have an idea ? Thank you
    • To post as a guest, your comment is unpublished.
      crystal · 1 years ago
      Hi Charlotte,
      Thank you for your comment. You can keep the file with macro for future use by saving the workbook as an Excel Macro-Enabled Workbook.
      For the formula problem, would you please provide a screenshot of your data? Thank you for your comment.
  • To post as a guest, your comment is unpublished.
    Cameron · 2 years ago
    I'm using that =IFERROR(INDEX($B$2:$B$9, MATCH(0,COUNTIF($D$1:D1, $B$2:$B$9), 0)),"") formula which is great for one column but my data is spread across a range of columns and rows. Can I edit the formula to include the whole area? My data lives from AC4 to AR60...
  • To post as a guest, your comment is unpublished.
    Alexis · 2 years ago
    Hi, thank you for your help.
    Now, how can I have my values also sorted alphabetically? (I do not want to use the filter on my master table)
    Should I use a COUNTIFS instead of COUNTIF?
    Please HELP
    • To post as a guest, your comment is unpublished.
      crystal · 2 years ago
      Hi Alexis,
      Sorry can't hep to sort the extracted value alphabetically at the same time with formula. Thank you for your comment.
  • To post as a guest, your comment is unpublished.
    Charley · 2 years ago
    I am trying to drag the formula down past my actual data so that I can input different sized data sets and not have to adjust anything. However, the last row after my actual data ends always returns a "0". I am using the unique values for something else in an adjacent column, and the 0 causes the last value to repeated (When I delete the 0 the value is no longer repeated). Any idea how to fix this? Also I am using Office 365 Business
  • To post as a guest, your comment is unpublished.
    parkerpress · 2 years ago
    If I do this for a thousand row excel sheet on the latest version of Excel on a Mac, it never returns. The first row works, but when I duplicate down, excel goes into a compute mode that has not returned values for over two hours now.

    Any thoughts on how to do this for large lists (up to 2k rows) that will return 50 or 60 unique values?

    I mocked this up in the "Numbers" app, and it's working perfectly there, taking only a couple minutes to calculate. It's just taking so long in Excel that I wonder if it will ever complete. I plan on letting it "run" overnight to see what will happen.
    • To post as a guest, your comment is unpublished.
      Josh · 2 years ago
      Check your Calculating options. It needs to be set to automatic. File > Options > Formulas > Calculating options > Workbook Calculation (Automatic selection)
  • To post as a guest, your comment is unpublished.
    Matt · 3 years ago
    How would you add a second variable? For instance, I want all the unique elements in one column that also share a similar value in another column. In your example, imagine a 3rd column titled "Department" that would have values like product, meat, etc. I realize those are all Produce, but hopefully you get my point. Would you modify the CountIF formula to a COUNTIFS or do you modify it in another way?
    • To post as a guest, your comment is unpublished.
      crystal · 2 years ago
      Hi Matt
      Please try this formula =IF(ISNA(VLOOKUP(A2,$C$2:$C$13,1,FALSE)),"Yes","").
      Supposing the two compared lists are Column A and Column C, If the unique values stay only in Column A but not in Column C, it will be displayed Yes in column B; while if return nothing in Column B, it means corresponding value stays in both Column A and Column C.
      • To post as a guest, your comment is unpublished.
        jyotiba mali · 2 years ago
        Thanks for the reply.. but hot to pull out that unique value if it displayed YES.. could you please advice me the formula to pull the unique value in different column.
  • To post as a guest, your comment is unpublished.
    Zac · 3 years ago
    How would you add multiple criteria, such as if you only wanted to add to the dynamic list if the date was just 9/12?

    I'm trying "&" in the MATCH formula, but it's not working.

    For example, based on your example:
    =IFERROR(INDEX($B$2:$B$9, MATCH(0 & B4,COUNTIF($D$1:D1, $B$2:$B$9) & $A$2:$A$9, 0)),"")
    This throws an error or creates duplicates.

    Alternatively, I've read that "+" might work, although I can't get it working. Or using SMALL.

    Ideas?
    • To post as a guest, your comment is unpublished.
      crystal · 3 years ago
      Dear Zac,
      Sorry I can’t help with this, you can post your question in our forum: https://www.extendoffice.com/forum.html to get more Excel supports from our professional.
  • To post as a guest, your comment is unpublished.
    Mike · 3 years ago
    Hi Crystal,
    I am trying to use the VB version of the unique values list and running into an issue.
    The range that I want to create a unique values column from is all formulas that refer to different tabs.
    How does one get the value to transfer over instead of the formula?
    • To post as a guest, your comment is unpublished.
      Odette · 3 years ago
      I have the same problem, except that my formula refer to column names and cannot convert to absolute.
      How do I change the vba to paste the values and not the formula?
    • To post as a guest, your comment is unpublished.
      crystal · 3 years ago
      Dear Mike,
      Please convert your formula references to absolute, and then apply the VB script.
  • To post as a guest, your comment is unpublished.
    Jones · 3 years ago
    Any tips on getting the VBA option to work with Excel 2016 for macOS? I have followed the steps; however, when I run the macro, nothing happens at all. Thanks!
    • To post as a guest, your comment is unpublished.
      crystal · 3 years ago
      Daer Jones,
      Please try the below VBA code and let me know whether it works for you. Thank you!

      Sub CreateUniqueList()
      Dim xRng As Range
      Dim xLastRow As Long
      Dim xLastRow2 As Long
      Dim I As Integer
      ' On Error Resume Next
      Set xRng = Application.InputBox("Please select range:", "Kutools for Excel", Selection.Address, , , , , 8)
      If xRng Is Nothing Then Exit Sub
      On Error Resume Next
      xRng.Copy Range("D2")
      xLastRow = xRng.Rows.Count + 1
      ActiveSheet.Range("D2:D" & xLastRow).RemoveDuplicates Columns:=1, Header:=xlNo
      xLastRow2 = Cells(Rows.Count, "B").End(xlUp).Row
      For I = 1 To xLastRow2
      If ActiveSheet.Range("D2:D" & xLastRow2).Cells(I).Value = "" Then
      ActiveSheet.Range("D2:D" & xLastRow2).Cells(I).Delete
      End If
      Next
      End Sub
  • To post as a guest, your comment is unpublished.
    Ryan · 3 years ago
    Also, for whatever reason, the original formula provided:
    =IFERROR(INDEX($B$2:$B$9, MATCH(0,COUNTIF($D$1:D1, $B$2:$B$9), 0)),"")

    returns a "circular reference" warning and will not calculate..
    • To post as a guest, your comment is unpublished.
      Andrew · 3 years ago
      I've had this happen before - my fix was that I was entering the formula into the cell D1 (equivalent in the worksheet I was using). Whichever cell the $D:$1 corresponds to you need to be entering it in the cell below - D2. Apologies if that's not why you got the error
    • To post as a guest, your comment is unpublished.
      crystal · 3 years ago
      Dear Ryan,
      Which Office version do you use? The formula works well in my Office 2016 and 2013.
  • To post as a guest, your comment is unpublished.
    Ryan · 3 years ago
    Hello, and thank you for your help.

    I need exactly this functionality, but my list of "unique values" needs to extend across columns instead of rows, so the expanding list down the rows won't work for me.

    How can I modify this formula in order to make the "unique values" list expand as I drag it across the columns?

    Offset()?
    Transpose()?
    Indirect() with a string of absolute references concatenated with a reference to the column instead of row?


    Thanks again!
    • To post as a guest, your comment is unpublished.
      crystal · 3 years ago
      Dear Ryan,
      This formula =IFERROR(INDEX($B$2:$B$9, MATCH(0,COUNTIF($D$2:D2, $B$2:$B$9), 0)),"") + Ctrl + Shift + Enter can help you to solve the problem.
      See below screenshot:
  • To post as a guest, your comment is unpublished.
    v.urala@gmail.com · 3 years ago
    {=INDEX($Q$3:$Q$263,MATCH(0,COUNTIF(V$2:V2,$Q$3:$Q$263),0))} - found this to work from another site...

    Use the Ctrl+Shift+Enter to get the array function (curly braces). Drag copy-paste the formulas until the #NA is shown. My data set was in Column-Q, it was compared to see if it existed in the unique's list in Column-V, which continually stretches along this same column.
    • To post as a guest, your comment is unpublished.
      crystal · 3 years ago
      Good Day.
      Please list all unique values of column Q with the abobv formula, and then use his formula =IF(D2=V1,"Match","No match") to compare if the uniques in cilumn Q compareing to column V in the same row.
  • To post as a guest, your comment is unpublished.
    Outdated · 3 years ago
    This formula is outdated and doesn't work. I literally just set this exact excel sheet up to see if I could get this formula to work and it doesnt.
    • To post as a guest, your comment is unpublished.
      crystal · 3 years ago
      Hey guy,
      Which Office version do you use?
  • To post as a guest, your comment is unpublished.
    PJ · 4 years ago
    I am decent at excel but I am really trying to wrap my head around how and why the above formula works (it works for what I am using it for but I must understand why). I get a little confused using arrays sometimes so any explanation in idiots terms would be extremely helpful

    Regards
  • To post as a guest, your comment is unpublished.
    Eric · 4 years ago
    Thank you for the tutorial. Using the formula method, how would you alter the formula if you wanted to add a category qualifer? Say in column C you distinguish whether the item is a fruit or a vegetable. How would you change the code to only sort the unique fruits and exclude the vegetables? I tried replacing COUNTIF with COUNTIFS, using the second countifs criteria of (LIST RANGE,"CATEGORY") but it returns blank. Would I need to expand my array and incorporate VLOOKUP?