+ Reply to Thread
Results 1 to 6 of 6

SUMIF where rows are compared

  1. #1
    Registered User
    Join Date
    01-25-2016
    Location
    London, UK
    MS-Off Ver
    2016
    Posts
    31

    SUMIF where rows are compared

    Hi,

    I have a column with strings, and an adjacent column with values. I want to apply SUMIF to sum those values, but I only need the values for rows where the text in that particular row is different from the row right below it. I tried a combination of SUMIF and OFFSET, but obviously that wasn't gonna work, as the reference in the OFFSET formula would apply to the whole range, and I don't want that. Is there a way to do this without VBA? Basically, for every row that is different from the row right below it, I want to get the values and have it summed.

    Thanks,
    Ed

  2. #2
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,915

    Re: SUMIF where rows are compared

    Hi, Welcome to the forum

    Please attach a sample excel file
    Samba

    Say thanks to those who have helped you by clicking Add Reputation star.

  3. #3
    Registered User
    Join Date
    01-25-2016
    Location
    London, UK
    MS-Off Ver
    2016
    Posts
    31

    Re: SUMIF where rows are compared

    Thanks Siva.
    I'm afraid that's going to be a bit problematic now. But imagine this,
    Column A
    Row 1 UK
    Row 2 UK
    Row 3 UK
    Row 4 Germany
    Row 5 Germany
    Row 6 Germany
    Row 7 France
    Row 8 France, etc.

    So I'd like to have the values from the B column summed for rows 3 and 6.

  4. #4
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,915

    Re: SUMIF where rows are compared

    Try
    =SUMPRODUCT((A1:A8<>A2:A9)*(B1:B8))
    or
    =SUMPRODUCT((A1:A8<>OFFSET(A1,1,,ROWS(A1:A8),))*(B1:B8))

  5. #5
    Registered User
    Join Date
    01-25-2016
    Location
    London, UK
    MS-Off Ver
    2016
    Posts
    31

    Re: SUMIF where rows are compared

    Great, thanks!

  6. #6
    Registered User
    Join Date
    01-25-2016
    Location
    London, UK
    MS-Off Ver
    2016
    Posts
    31

    Re: SUMIF where rows are compared

    Quote Originally Posted by nflsales View Post
    Try
    =SUMPRODUCT((A1:A8<>A2:A9)*(B1:B8))
    or
    =SUMPRODUCT((A1:A8<>OFFSET(A1,1,,ROWS(A1:A8),))*(B1:B8))
    By the way, why do you have to specify the height in the offset function?

+ 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. Replies: 0
    Last Post: 03-07-2014, 04:01 PM
  2. [SOLVED] =IF function with 4 Cells that need compared
    By mmanning in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 09-26-2013, 12:32 PM
  3. Two Spreadsheets need compared for Yes and Blank
    By cvolpe814 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 08-06-2012, 04:13 PM
  4. VBA addin - ODBC via ADO compared to DAO
    By popfan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-10-2012, 11:20 AM
  5. Value compared to a range of values
    By skazis in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-06-2011, 09:44 AM
  6. 6 sets of data compared
    By corster in forum Excel General
    Replies: 3
    Last Post: 02-07-2010, 06:35 AM
  7. [SOLVED] Calculating rows and columns compared to a given cell
    By clippan in forum Excel General
    Replies: 1
    Last Post: 02-27-2006, 12:15 PM
  8. Replies: 2
    Last Post: 01-12-2006, 10:55 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