+ Reply to Thread
Results 1 to 26 of 26

Remove Duplicates

Hybrid View

  1. #1
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,342

    Re: Remove Duplicates

    no problems it takes a while to get the hang of it
    this one is for extraction the duplicates and removes the spaces
    Option Explicit
    Sub ptestu()
        Dim p!, i!, k(), e
        With Range("a1", Range("a" & Rows.Count).End(xlUp)).Resize(, 1)
            e = .Value
            ReDim k(UBound(e, 1), 1)
            With CreateObject("Scripting.Dictionary")
                .CompareMode = vbTextCompare
                For i = 1 To UBound(e, 1)
                    If Not IsEmpty(e(i, 1)) Then
                        e(i, 1) = Trim(e(i, 1))
                        If Not .exists(e(i, 1)) Then
                            k(p, 0) = e(i, 1)
                            .Add e(i, 1), p
                            p = p + 1
                        End If
                    End If
                Next
            End With
            .ClearContents
        End With
        Range("a1").Resize(p, 1).Value = k
    End Sub
    this one is to clean the duplicated raw data
    it was for your calculation as they woudnt sum while the spaces
    Sub ptwo()
    Dim p!, i!, k(), e
    With Range("a1", Range("a" & Rows.Count).End(xlUp)).Resize(, 1)
            e = .Value
        p = .Rows.Count
     
     ReDim k(UBound(e, 1), 1)
    For i = 1 To UBound(e, 1)
      k(i, 1) = Trim(e(i, 1))
     Cells(i, 1) = k(i, 1)
    Next
    End With
    End Sub
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

  2. #2
    Registered User
    Join Date
    01-22-2008
    Posts
    50

    Re: Remove Duplicates

    cool. i seperated the (2) macros, and successfully ran the first dedupe one.

    the second one (for sumif) runs, but it doesn't remove the dups. i've attached new file. now, what am i doing wrong?
    Attached Files Attached Files

+ 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