Results 1 to 26 of 26

Macro to count duplicates then number them in a separate column

Threaded View

  1. #1
    Registered User
    Join Date
    05-27-2015
    Location
    london
    MS-Off Ver
    2003
    Posts
    22

    Macro to count duplicates then number them in a separate column

    Hi,

    I love excell but am struggling with a macro. I hope someone can help.

    I am trying to create a macro that will take the values of columnB, count the duplicates then display the values in columnE with the total number of value duplicates in ColumnF


    I sourced this code which does something like I want but I cant split the Value B data(Code is A) into separate columns. I might be over thinking it. Code below.


    Sub Summary()
    '
    '
        Dim rngData As Range
        Dim rngUniqueData As Range
        Dim lngRow As Long
        Dim lngCount As Long
    '
        Set rngData = Range("A1", Range("A1").End(xlDown))
       
        rngData.AdvancedFilter Action:=xlFilterCopy, _
                               CopyToRange:=rngData.Cells(1, 1).Offset(0, 1), Unique:=True
           
        Set rngUniqueData = Range("B1", Range("B1").End(xlDown))
       
        With rngUniqueData
            For lngRow = 2 To .Rows.Count
                lngCount = Application.WorksheetFunction.CountIf(rngData, .Cells(lngRow, 1).Value)
                .Cells(lngRow, 1).Value = .Cells(lngRow, 1).Value & " - " & lngCount & IIf(lngCount > 1, " copies", " copy")
            Next
        End With
       
    End Sub
    Last edited by paperbo; 01-11-2018 at 12:15 PM. Reason: Request to comply with rules

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] count duplicates in Column E in all worksheets and write their number in Column H
    By wali in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-13-2015, 06:19 AM
  2. Count number of cells associated with value in separate column
    By lamdl in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-13-2014, 03:48 PM
  3. Replies: 2
    Last Post: 09-25-2013, 10:14 AM
  4. [SOLVED] Count Duplicates in Column A once as long as there is a number higher than 0 in Column B
    By armbands1 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-05-2013, 01:46 AM
  5. [SOLVED] Macro to count unique values in a column, enter it in next column, then delete duplicates
    By pmorisse in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-25-2013, 03:27 PM
  6. Count duplicates and put their number in next column
    By wali in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-21-2011, 05:59 PM
  7. Count number of unique items in a column that contains duplicates
    By Steembeem in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-01-2005, 09:06 PM

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