+ Reply to Thread
Results 1 to 15 of 15

Sum of cell in different rows (dynamic)

  1. #1
    Forum Contributor
    Join Date
    05-17-2016
    Location
    Montreal
    MS-Off Ver
    2013
    Posts
    115

    Sum of cell in different rows (dynamic)

    Hey y'all!

    Essentially, is there a way to automatically sum the values from different rows/columns dynamically:

    Example: G = F - (lookup value) - B
    G25 = F23 - B25

    I.e. It will look at F25/ if nothing --> F24/if nothing --> F23/ Has a value

    (Please see excel file)

    I've tried several different ways of stating it in IF statement without success

    Any help would be much appreciated
    Attached Files Attached Files
    Last edited by Exequiel3k; 05-19-2016 at 01:30 PM.

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,206

    Re: Sum of cell in different rows (dynamic)

    Used helper column in H

    h17 and copy down

    =IF(F17=0,H16,ROWS($1:1))

    in G17

    =IF(SUM($B17:$E17)>0,INDEX($F$17:$F$27,$H17)-SUM($B17:$E17),"")

    Copy down
    Attached Files Attached Files

  3. #3
    Forum Expert José Augusto's Avatar
    Join Date
    10-29-2014
    Location
    Portugal
    MS-Off Ver
    2013-2016
    Posts
    3,329

    Re: Sum of cell in different rows (dynamic)

    Hi Exequiel

    try this formula in G17 and copy down.
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    See the file data.xlsx for clarification

  4. #4
    Forum Contributor
    Join Date
    05-17-2016
    Location
    Montreal
    MS-Off Ver
    2013
    Posts
    115

    Re: Sum of cell in different rows (dynamic)

    Thanks for taking the time to reply back

    The thing is new data will be fed to it consistently. In the data excel file (i provided) it worked flawlessly but the main excel file it doesn't (#value! error).. maybe because there are over 3k rows?
    Would something have to change around the AGGREGATE section to reflect that??
    Last edited by Exequiel3k; 05-19-2016 at 03:10 PM.

  5. #5
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,206

    Re: Sum of cell in different rows (dynamic)

    The ranges B17:E17, A17, F17 will need to be changed; can you supply the ranges where data is in your production file. Are there just columns as per your sample.

    Perhaps post a file showing your production file format (no data needed).

  6. #6
    Forum Contributor
    Join Date
    05-17-2016
    Location
    Montreal
    MS-Off Ver
    2013
    Posts
    115

    Re: Sum of cell in different rows (dynamic)

    It exceeds the limit -_-`:@ but i took a snapshot of the section..Attachment 461706Attachment 461707
    Attached Images Attached Images
    Last edited by Exequiel3k; 05-20-2016 at 09:17 AM.

  7. #7
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,206

    Re: Sum of cell in different rows (dynamic)

    The system will not me view the attachment: I only wanted to know the ranges _ I don't need any data.

  8. #8
    Forum Contributor
    Join Date
    05-17-2016
    Location
    Montreal
    MS-Off Ver
    2013
    Posts
    115

    Re: Sum of cell in different rows (dynamic)

    I've attached a file showing the range.., since rows will be infinite
    (it really goes from A -> BC)
    Attached Files Attached Files
    Last edited by Exequiel3k; 05-19-2016 at 04:02 PM.

  9. #9
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,206

    Re: Sum of cell in different rows (dynamic)

    Working from the image ...

    this in AW5

    =IF(MAX(AA5:AE5)<>0,INDEX($AW$5:$AW$50,AGGREGATE(14,6,ROW($A$5:$A5)*($AW$5:$AW5<>""),1)-4,1)-MAX(AA5:AE5),"")

    Assumes data starts in row 5 and finishes at row 50. If it starts in 12 then change 5 to 12 and -4 to -11

    the ranges in the image are totally out of sync.

  10. #10
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,206

    Re: Sum of cell in different rows (dynamic)

    A more generic version

    =IF(MAX(AA5:AE5)<>0,INDEX($AW$5:$AW$50,AGGREGATE(14,6,ROW($A$5:$A5)*($AW$5:$AW5<>""),1)-ROW($A$5)+1,1)-MAX(AA5:AE5),"")

    will need to change 5 to start row

  11. #11
    Forum Contributor
    Join Date
    05-17-2016
    Location
    Montreal
    MS-Off Ver
    2013
    Posts
    115

    Re: Sum of cell in different rows (dynamic)

    I can't get it to work...
    I've striped the excel file so I can upload it. It's best this way :p
    Attached Files Attached Files
    Last edited by Exequiel3k; 05-20-2016 at 09:44 AM.

  12. #12
    Forum Contributor
    Join Date
    05-17-2016
    Location
    Montreal
    MS-Off Ver
    2013
    Posts
    115

    Re: Sum of cell in different rows (dynamic)

    Alright, so it works though after 50rows it cuts.. Is there a way for it to never cut no matter the number of rows (ie infinit rows)???

    Btw, thank you all for helping me
    Attached Files Attached Files

  13. #13
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,206

    Re: Sum of cell in different rows (dynamic)

    Simply change the upper limit of the range ...5000 in the formula below (10000? 100000? ... choice is yours but keep it sensible)

    =IF(MAX(AA5:AE5)<>0,INDEX($AW$5:$AW$5000,AGGREGATE(14,6,ROW($A$5:$A5)*($AW$5:$AW5<>""),1)-ROW($A$5)+1,1)-MAX(AA5:AE5),"")

  14. #14
    Forum Contributor
    Join Date
    05-17-2016
    Location
    Montreal
    MS-Off Ver
    2013
    Posts
    115

    Re: Sum of cell in different rows (dynamic)

    Thx for the reply, what I did was just remove the "$" before it.. Do you think in the long-run that could be problimatic??

    =IF(MAX(AA5:AE5)<>0,INDEX($AW$5:$AW$500,AGGREGATE(14,6,ROW($A$5:$A5)*($AW$5:$AW5<>""),1)-ROW($A$5)+1,1)-MAX(AA5:AE5),"")

  15. #15
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,206

    Re: Sum of cell in different rows (dynamic)

    Should be OK.

+ 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. [SOLVED] Clear dynamic named sheet, compare cells from 2 sheets, copy all matched rows to dynamic s
    By drewship in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 12-15-2015, 12:31 PM
  2. comparing two rows in dynamic cell range
    By 3MMM in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-21-2014, 06:46 PM
  3. Dynamic: Adding up the previous 3 rows from a given cell
    By Dreamer12 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-24-2014, 10:56 AM
  4. [SOLVED] Macro to copy/paste cell into same column down a dynamic number of rows
    By rdowney79 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-31-2013, 03:03 PM
  5. [SOLVED] 2010VBA AutoHide(&unhide) rows based on dynamic cell value
    By epicurean in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-14-2013, 01:30 PM
  6. Replies: 5
    Last Post: 12-06-2012, 06:52 PM
  7. [SOLVED] How to hide rows based on cell value, row range is dynamic.
    By csh8428 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-03-2012, 02:05 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