Consulting

Results 1 to 4 of 4

Thread: Solved: unique values with sumif

  1. #1
    VBAX Tutor
    Joined
    Nov 2007
    Posts
    291
    Location

    Solved: unique values with sumif

    I have a spreadsheet with account numbers and balances and am doing a sumif on them. However some clients have subaccounts and thus doing a sumif on the account number (which I want) gives several of the same values. Is there a way in VBA to fill a column with sumif formulae but only return unique results?

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    SUMIF will return a result of an amount range where another range equals the criteria. It doesn't produce a list of the items that match. Are you after the latter, or just a count of each of the sub-accounts within the account? Or even something else.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Tutor
    Joined
    Nov 2007
    Posts
    291
    Location
    Lets say I have :-


    Acc Sub Amount
    Code Code

    57187 25 1,000
    57187 10 2,000
    57187 30 1,500
    58186 25 8,000
    58186 45 9,000
    52189 25 8,000

    In the end column I enter =SumIF("A:A",A1,"C:C") then copy the formula down.

    In the first three cells I get 4,500 then in the next two I get 17,000 then in the last cell I get 8,000

    Obviously my sheet is much larger and with more "stuff" in it but this is just an example.

    I just want the total for 57187 once i.e. 4,500 to appear once, then 17,000 the total for 58186 to appear once and so on

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    =IF(COUNTIF($A$1:A1,A1)>1,"",SUMIF(A:A,A1,C:C))
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

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