+ Reply to Thread
Results 1 to 3 of 3

Removing duplicates

Hybrid View

  1. #1
    Registered User
    Join Date
    05-11-2007
    Location
    Belgium
    Posts
    68

    first idea

    I just finished a more or less the same job.
    I tried two approaches but finally I used the easied one.

    1. FIRST SOLUTION.
    Place the worksheet function to determine the double entries. The COUNTIF takes a cell value and look if this appears in a range. If there is 1 or more appearance he set D (Duplicate) in a Column.
    range1 = "D3:D" & LastRow
    Sheet20.Range("A3:A" & LastRow).Formula = "=IF(COUNTIF(" & range1 & ",D3)>1,""D"",""F"")"
    With a short IIF you delete the D's for example.

    2. SECOND SOLUTION :
    A complete sub or function dat delete every double without writing the COUNTIF function to you sheet.

    If you want some more explanation or feedback or code, ask ....
    Last edited by matrixknow; 06-27-2007 at 08:17 AM.

  2. #2
    Registered User
    Join Date
    06-25-2007
    Location
    London
    Posts
    5
    ... me! Here is something that works quite nicely for me. There may be a neater way but hey it works!


    Dim N 'number of rows
    Dim i 'row number of lookup
    Dim j 'row number of search
    Dim x 'number of destinct
    Dim y 'duplicate toggle
    
    x = 1
    N = 1
    
    'count the number of non blank rows
    While Sheets("sheet1").Cells(N, 1).Value <> ""
    N = N + 1
    Wend
    
    'search for duplicates
    For i = 1 To N
    strLkup = Sheets("sheet1").Cells(i, 1).Value
    y = 0 'set to 0 for no duplicate found
    For j = 1 To i
    strSrch = Sheets("sheet1").Cells(j, 2).Value
    If strLkup = strSrch Then
    y = 1 'duplicates found
    Else
    End If
    Next
    
    'log the destinct values
    If y = 0 Then
    Sheets("sheet1").Cells(x, 2).Value = strLkup
    x = x + 1
    End If
    
    Next

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1