+ Reply to Thread
Results 1 to 7 of 7

Summing of one field where multiple fields have to be similar

  1. #1
    Registered User
    Join Date
    05-08-2013
    Location
    Monterey, California
    MS-Off Ver
    Excel 2007
    Posts
    40

    Summing of one field where multiple fields have to be similar

    I have a spreadsheet with 4 fields. One of the fields is numeric.

    If all three of the fields (string) are equal to another line, then I want to add up the estimated numbers. Basically what I want to be left with is unique values for the three string fields with a total estimated number. There is no logic to what the values in the three string fields can be - they just have to be the same, and there could be any number of records in addition.

    I have been wrestling with doing loops, or even a pivot table, but am not getting exactly what I am looking for.

    Any help would be greatly appreciated. I have attached a spreadsheet.

    Eric
    Attached Files Attached Files

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,762

    Re: Summing of one field where multiple fields have to be similar

    You can put this formula in D2 of your Desired sheet:

    =SUMIFS(Original!D:D,Original!A:A,A2,Original!B:B,B2,Original!C:C,C2)

    then copy down.

    Hope this helps.

    Pete

  3. #3
    Valued Forum Contributor
    Join Date
    04-24-2014
    Location
    United States
    MS-Off Ver
    Office 365 ProPlus
    Posts
    853

    Re: Summing of one field where multiple fields have to be similar

    Somebody with more experience in VBA can probably offer an elegant solution, and I'll try and experiment more on my own.....

    But I was wondering.... Can you possibly accomplish a similar result with the built in sumifs formula? For example, based on your sample, this formula provides a value of 36 for the

    =SUMIFS(D2:D22,A2:A22,"1a",B2:B22,"blue",C2:C22,"wet")

    I would think possible a combination of getting all the unique value for the first 3 columns and then sum if on each combination through a loop may do the trick.... But i'm still no expert at this stuff. I'll try and experiment here, but someone else may have a better, faster answer.

  4. #4
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,762

    Re: Summing of one field where multiple fields have to be similar

    I didn't realise that you wanted to generate the list as well - here's a simple formula approach:

    Put this formula in E2 of the Original sheet:

    =IF(COUNTA(A2:C2)=0,"",IF(COUNTIFS(A$2:A2,A2,B$2:B2,B2,C$2:C2,C2)=1,MAX(E$1:E1)+1,""))

    Copy this down as far as you need to - it will result in a sequential number each time a new combination is encountered.

    Then you can use this formula in A2 of the Desired sheet:

    =IFERROR(INDEX(Original!A:A,MATCH(ROWS($1:1),Original!$E:$E,0)),"")

    Copy this across into B2:C2, then copy A2:C2 down until you start getting blanks. Then you can use the formula I gave you earlier in D2, i.e.:

    =SUMIFS(Original!D:D,Original!A:A,A2,Original!B:B,B2,Original!C:C,C2)

    and copy this down.

    The list appears in a different order than in your sheet, but you can always fix the values then sort the table how you wish.

    Hope this helps.

    Pete

  5. #5
    Valued Forum Contributor
    Join Date
    04-24-2014
    Location
    United States
    MS-Off Ver
    Office 365 ProPlus
    Posts
    853

    Re: Summing of one field where multiple fields have to be similar

    I also did some further experimenting, and the below is pretty rough with fixed ranges. But it makes a copy of the worksheet, removes the duplicates and the sumifs each result.

    I think this is working for you?

    Actually.......forget the below as I just realized its not quite right. But it may give start for a VBA approach.

    Please Login or Register  to view this content.
    Last edited by ptmuldoon; 04-12-2016 at 09:48 PM.

  6. #6
    Registered User
    Join Date
    05-08-2013
    Location
    Monterey, California
    MS-Off Ver
    Excel 2007
    Posts
    40

    Re: Summing of one field where multiple fields have to be similar

    Thank you all! I will dig into this tomorrow. Appreciate your help.

  7. #7
    Valued Forum Contributor
    Join Date
    04-24-2014
    Location
    United States
    MS-Off Ver
    Office 365 ProPlus
    Posts
    853

    Re: Summing of one field where multiple fields have to be similar

    I spent some more time this morning via both some web searches and the macro recorder and came up with the below. This is still 'rough' with some hard coded ranges, but I believe gets the desired result.

    Sample attached

    Please Login or Register  to view this content.
    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)

Similar Threads

  1. break apart a field into multiple fields?
    By Geomorphic in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-25-2013, 11:41 PM
  2. Extracting and summing similar data from multiple worksheets
    By haskenazi in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 01-22-2013, 11:34 PM
  3. Summing respective fields from Multiple workbooks to one Consolidating File
    By dawnmau in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-08-2011, 05:52 PM
  4. Scrunching Multiple Record Fields Into One Top-level Field
    By SWMagic in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-25-2010, 01:00 PM
  5. Combining Multiple Columns/Fields into One Field
    By jus214 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-22-2009, 07:54 PM
  6. Replies: 1
    Last Post: 11-03-2008, 04:34 PM
  7. Summing accross multiple tabs for specific fields
    By doug2 in forum Excel General
    Replies: 2
    Last Post: 09-11-2007, 10:58 AM
  8. Summing Fields with Multiple Criteria
    By bpliskow in forum Excel General
    Replies: 1
    Last Post: 02-17-2006, 01:45 PM

Tags for this Thread

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