LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Count duplicates as unique record, sum amounts?

I have a spreadsheet will a large amount of invoice numbers, some of
which are multiple occurrences of the same number. I need to count the
duplicates as one unique record and sum but I need to sum the total $
amount of each amount attached to each occurrence. For Example, say
Invoice Number W234678 has 10 occurrences and corresponding amounts. I
need the amounts to be added to give a total amount for that number
and then have Invoice Number W234678 added to the count as one
record.
I had this code kindly borrowed from this board which helped me find
the duplicates but it is not meeting my needs.

Thanks in advance for any help!

Code:
Dim rCell As Range, rRng As Range, vKey, lrow As Long



Set rRng = Range("F2:F199")



With CreateObject("Scripting.dictionary")

    .comparemode = vbTextCompare



    ' load the info

    For Each rCell In rRng

        If Not .exists(rCell.Value) Then _

            .Add rCell.Value,
Application.WorksheetFunction.CountIf(rRng, rCell.Value)

    Next rCell



    ' Write the result in columns J:K

    lrow = 2

    For Each vKey In .keys

        If .Item(vKey)  1 Then

            Cells(lrow, "J") = vKey

            Cells(lrow, "K") = .Item(vKey) - 1

            lrow = lrow + 1

        End If

    Next vKey

End With

End Sub
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
unique record count with multiple criteria Rick Excel Worksheet Functions 1 February 12th 09 06:17 PM
Attempting to sort unique/only count first record in each unique g MJW[_2_] Excel Discussion (Misc queries) 3 August 10th 07 02:56 PM
Count Unique Values In A Filtered Row with Duplicates jcpotwor Excel Discussion (Misc queries) 1 January 13th 06 01:02 AM
Count unique values among duplicates in a subtotal range jcpotwor Excel Discussion (Misc queries) 2 January 12th 06 01:29 PM
Count number of unique items in a column that contains duplicates Steembeem Excel Worksheet Functions 3 February 2nd 05 12:51 AM


All times are GMT +1. The time now is 12:06 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"