• Privacywetgeving
    Het is bij Helpmij.nl niet toegestaan om persoonsgegevens in een voorbeeld te plaatsen. Alle voorbeelden die persoonsgegevens bevatten zullen zonder opgaaf van reden verwijderd worden. In de vraag zal specifiek vermeld moeten worden dat het om fictieve namen gaat.

Verwijderen rijen van dubbele waarden uit één kolom

Status
Niet open voor verdere reacties.

Ron79

Gebruiker
Lid geworden
21 nov 2005
Berichten
255
Eén goeiemiddag!

Ik heb al even rondgekeken maar de oplossing voor mijn 'probleem' niet tegen gekomen (geloof ik...)

Ik heb een werkblad met daarin meerdere kolommen met unieke waarden, behalve één kolom (ik noem 'm even 'C') waarin dubbele waarden staan.
Van deze kolom wil ik de dubbele waarden verwijderen inclusief de rij waarin deze waarde staat. Van elke dubbele waarde in Kolom C blijft er dus één unieke waarde mét bijbehorende rij over.

Ben ik zo een beetje duidelijk? ;)


Bedankt alvast! :thumb:
 
Ron,

Het makkelijkst is om in D1 te zetten
Code:
=ALS(AANTAL.ALS(C:C;C1)>1;"x";"")
Deze trek je naar naar de laatste regel van je bestand. Vervolgens filter je op D en kiest voor x. Die regels kun je nu markeren en verwijderen.
 
Hoi Rob,

Bedankt voor je reactie! :thumb:

Dit is bij-na wat ik bedoel, ik wil graag van alle dubbele waarden er één (met gehele bijbehorende regel) overhouden. Nog een goed idee?

Maar dit was, ook al heb ik er nu niets aan, wel een leermomentje voor me dus die heb al wel alvast in de pocket! :cool:


Ron
 
dubbele rijen verwijderen

Je kan ook een advanced filter gebruiken, en dan alleen unieke waardes weergeven.

Onderstaande code ooit eens ergens gevonden (ik heb deze niet geschreven):

Code:
DeleteDuplicateRows

This macro will delete duplicate rows in a range.* To use, select a single-column range of cells, comprising the range of rows from which duplicates are to be deleted, e.g., C2:C99.** To determine whether a row has duplicates, the values in the selected column are compared. Entire rows are not compared against one another.* Only the selected column is used for comparison.* When duplicate values are found in the active column, the first row remains, and all subsequent rows are deleted.

Public Sub DeleteDuplicateRows()
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' DeleteDuplicateRows
' This will delete duplicate records, based on the Active Column. That is,
' if the same value is found more than once in the Active Column, all but
' the first (lowest row number) will be deleted.
'
' To run the macro, select the entire column you wish to scan for
' duplicates, and run this procedure.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Dim R As Long
Dim N As Long
Dim V As Variant
Dim Rng As Range

On Error GoTo EndMacro
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual


Set Rng = Application.Intersect(ActiveSheet.UsedRange, _
******************* ActiveSheet.Columns(ActiveCell.Column))

Application.StatusBar = "Processing Row: " & Format(Rng.Row, "#,##0")

N = 0
For R = Rng.Rows.Count To 2 Step -1
If R Mod 500 = 0 Then
*** Application.StatusBar = "Processing Row: " & Format(R, "#,##0")
End If

V = Rng.Cells(R, 1).Value
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Note that COUNTIF works oddly with a Variant that is equal to vbNullString.
' Rather than pass in the variant, you need to pass in vbNullString explicitly.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
If V = vbNullString Then
*** If Application.WorksheetFunction.CountIf(Rng.Columns(1), vbNullString) > 1 Then
******* Rng.Rows(R).EntireRow.Delete
******* N = N + 1
*** End If
Else
*** If Application.WorksheetFunction.CountIf(Rng.Columns(1), V) > 1 Then
******* Rng.Rows(R).EntireRow.Delete
******* N = N + 1
*** End If
End If
Next R

EndMacro:

Application.StatusBar = False
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
MsgBox "Duplicate Rows Deleted: " & CStr(N)

End Sub
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan