+ Reply to Thread
Results 1 to 20 of 20

formula to calculate cell values from previous cell calculation

  1. #1
    Registered User
    Join Date
    09-05-2018
    Location
    UK
    MS-Off Ver
    Windows - Microsoft 365
    Posts
    18

    Post formula to calculate cell values from previous cell calculation

    Hi guys

    New to the forum, looking to increase my knowledge within Excel primarily focussed towards formulas

    I am working on a spreadsheet where at the minute I am manually having to do a formula in each cell i wanted to know if there is a quicker efficient solution

    I have values in two columns but I want to calculate the previous cell to the cell in the left and result to go in a new cell so for example


    24 3892
    39 3931
    3 3934
    7
    15

    so next cell would be = 3934 + 7 = 3941 and then the following would be 3941 + 15 = 3956 and so forth

    At the minute i am doing this manually is there any way I can do this quickly by just dragging the formula down
    Last edited by ash2019; 09-05-2018 at 05:17 AM.

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

    Re: formula to calculate cell values from previous cell calculation

    Assuming your data is in columns A and B, then you can put this formula in B2:

    =IF(A2="","",A2+B1)

    then copy this down.

    Hope this helps.

    Pete

  3. #3
    Registered User
    Join Date
    09-05-2018
    Location
    UK
    MS-Off Ver
    Windows - Microsoft 365
    Posts
    18

    Re: formula to calculate cell values from previous cell calculation

    Quote Originally Posted by Pete_UK View Post
    Assuming your data is in columns A and B, then you can put this formula in B2:

    =IF(A2="","",A2+B1)

    then copy this down.

    Hope this helps.

    Pete
    Hi Pete

    Thanks for your swift response

    my columns are C and E but E is blank until I have done the formula

    I have tried your formula but is is not generating a result

  4. #4
    Registered User
    Join Date
    09-05-2018
    Location
    UK
    MS-Off Ver
    Windows - Microsoft 365
    Posts
    18

    Re: formula to calculate cell values from previous cell calculation

    i have got the formula working but when i drag the formula down it does not work

    =IF(C4272="","",C4272+E4253)

    if i delete E4253 and then reference the previous cell the correct result appears but does not work when i drag the formula down, any ideas?

    E4253 is the cell where the previous value was calculated
    Last edited by ash2019; 09-05-2018 at 06:05 AM.

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

    Re: formula to calculate cell values from previous cell calculation

    It would help if you attached a sample Excel workbook, as those cell references bear no relation to what you first posted.

    To do this, click on Go Advanced (below the Edit Window) while you are composing a reply, then scroll down to and click on Manage Attachments and the Upload window will open. Click on Browse and navigate to (and double-click) the file icon that you want to attach, then click on Upload and then on Close this Window to return to the Edit window. When you have finished composing your post, click on Submit Post.

    Pete

  6. #6
    Registered User
    Join Date
    09-05-2018
    Location
    UK
    MS-Off Ver
    Windows - Microsoft 365
    Posts
    18

    Re: formula to calculate cell values from previous cell calculation

    Hi Pete

    I have attached the spreadsheet
    Attached Files Attached Files

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

    Re: formula to calculate cell values from previous cell calculation

    You have a lot of #REF! errors towards the bottom of your sheet - perhaps you have deleted some rows. To avoid those, you can put this formula in D4:

    =IF(OR(ISERROR(B4),ISERROR(C4)),"",IF(C4="H",B4+IF(COUNT(D$3:D3)=0,0,LOOKUP(9000000000,D$3:D3)),""))

    then copy the formula down as far as you need to.

    Hope this helps.

    Pete

  8. #8
    Forum Expert
    Join Date
    12-11-2011
    Location
    Netherlands
    MS-Off Ver
    office 365
    Posts
    3,654

    Re: formula to calculate cell values from previous cell calculation

    =IF(A4<A5;ROW()-2;"")
    I think if all your #REF! are recoverd this formula will work
    Attached Files Attached Files
    Willem
    English is not my native language sorry for errors
    Please correct me if I'm completely wrong

  9. #9
    Registered User
    Join Date
    09-05-2018
    Location
    UK
    MS-Off Ver
    Windows - Microsoft 365
    Posts
    18

    Re: formula to calculate cell values from previous cell calculation

    Quote Originally Posted by Pete_UK View Post
    You have a lot of #REF! errors towards the bottom of your sheet - perhaps you have deleted some rows. To avoid those, you can put this formula in D4:

    =IF(OR(ISERROR(B4),ISERROR(C4)),"",IF(C4="H",B4+IF(COUNT(D$3:D3)=0,0,LOOKUP(9000000000,D$3:D3)),""))

    then copy the formula down as far as you need to.

    Hope this helps.

    Pete
    Apologies Pete, those REF are due to me deleting rows to simplify the spreadsheet, so those are relevant

    I have attached another spreadsheet which I hopes make sense, I want to copy the formula down but at the minute I am doing it one by one which is very time consuming!

    Thanks
    Attached Files Attached Files
    Last edited by ash2019; 09-05-2018 at 02:54 PM.

  10. #10
    Registered User
    Join Date
    09-05-2018
    Location
    UK
    MS-Off Ver
    Windows - Microsoft 365
    Posts
    18

    Re: formula to calculate cell values from previous cell calculation

    Hi Pete,

    I would appreciate your input, I have hundreds of rows where I am doing the formula manually your solution would be welcomed

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

    Re: formula to calculate cell values from previous cell calculation

    In your latest attachment, put this formula in B3:

    =IF(A3="","",A3+B2)

    then copy it down as far as you want.

    Hope this helps.

    Pete

  12. #12
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: formula to calculate cell values from previous cell calculation

    maybe this in B2, copied down as far as needed:

    =IF(A2="","",SUM($A$2:A2))
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU

  13. #13
    Registered User
    Join Date
    09-05-2018
    Location
    UK
    MS-Off Ver
    Windows - Microsoft 365
    Posts
    18

    Re: formula to calculate cell values from previous cell calculation

    Quote Originally Posted by Pete_UK View Post
    In your latest attachment, put this formula in B3:

    =IF(A3="","",A3+B2)

    then copy it down as far as you want.

    Hope this helps.

    Pete
    Hi Pete

    That formula works perfectly in the example spreadsheet i provided

    however when i do the same formula in the actual spreadsheet I am working on the calculations are incorrect

    I think this is because I have filters in place on alot of rows which need to be in place, is there a solution to address this?

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

    Re: formula to calculate cell values from previous cell calculation

    If your real file is more like the one you posted in Post #6, then I have corrected the source of the #REF! errors and put this formula in D4:

    =IF(C4="H",B4+IF(COUNT(D$3:D3)=0,0,LOOKUP(9000000000,D$3:D3)),"")

    which has been copied down to the bottom of your data (and could be copied further if more data is to be added).

    Is this what you are after?

    Hope this helps.

    Pete
    Attached Files Attached Files

  15. #15
    Registered User
    Join Date
    09-05-2018
    Location
    UK
    MS-Off Ver
    Windows - Microsoft 365
    Posts
    18

    Re: formula to calculate cell values from previous cell calculation

    Quote Originally Posted by Pete_UK View Post
    If your real file is more like the one you posted in Post #6, then I have corrected the source of the #REF! errors and put this formula in D4:

    =IF(C4="H",B4+IF(COUNT(D$3:D3)=0,0,LOOKUP(9000000000,D$3:D3)),"")

    which has been copied down to the bottom of your data (and could be copied further if more data is to be added).

    Is this what you are after?

    Hope this helps.

    Pete
    Hi Pete

    Thats perfect, thanks for all your help!

    I am trying to increase my knowledge within Excel, for my benefit keen to know what the formula is actually doing, could you break it down and explain?

    Cheers!

  16. #16
    Forum Expert
    Join Date
    12-11-2011
    Location
    Netherlands
    MS-Off Ver
    office 365
    Posts
    3,654

    Re: formula to calculate cell values from previous cell calculation

    What is wrong with this simple formula:
    Please Login or Register  to view this content.

  17. #17
    Registered User
    Join Date
    09-05-2018
    Location
    UK
    MS-Off Ver
    Windows - Microsoft 365
    Posts
    18

    Re: formula to calculate cell values from previous cell calculation

    Quote Originally Posted by popipipo View Post
    What is wrong with this simple formula:
    Please Login or Register  to view this content.
    I have tried this formula too but for some reason I keep getting an error message appear

  18. #18
    Registered User
    Join Date
    09-05-2018
    Location
    UK
    MS-Off Ver
    Windows - Microsoft 365
    Posts
    18

    Re: formula to calculate cell values from previous cell calculation

    Quote Originally Posted by ash2019 View Post
    Hi Pete

    Thats perfect, thanks for all your help!

    I am trying to increase my knowledge within Excel, for my benefit keen to know what the formula is actually doing, could you break it down and explain?

    Cheers!
    Hi Pete

    I have many tabs which have the same data but the H is located in different rows, the H represents the total occasions the date appears

    so what I am having to do is adjust the first formula to reference it to where the H and total overall figure ends before the next count of the date begins appears then copy it to down to the remaining H occurrences, is there any way this can be avoided as it would be nice just to copy and paste the formula without having to adjust it each time for each sheet.

    Also I have thousands of rows of data, is there a quick way to fill the column with the same formula to the bottom of where the data ends? currently I am using the drag method, i am using excel 2016

    thank you once again
    Last edited by ash2019; 09-07-2018 at 07:32 AM.

  19. #19
    Forum Expert
    Join Date
    12-11-2011
    Location
    Netherlands
    MS-Off Ver
    office 365
    Posts
    3,654

    Re: formula to calculate cell values from previous cell calculation

    I don't have any error
    Attached Files Attached Files

  20. #20
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,950

    Re: formula to calculate cell values from previous cell calculation

    An alternative:
    1. With no formulas in column B (just the header), select A1:B1 down to last row in A
    2. Data menu
    a) Advanced
    b) Select: Copy to another location (choose, say, E1)
    c) Check "Unique record only"
    d) o.k.
    3. In cell E2, enter:
    Please Login or Register  to view this content.
    and fill down.
    Attached Files Attached Files
    Ben Van Johnson

+ 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] Calculation based upon previous cell
    By hanif in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 01-25-2017, 11:56 AM
  2. [SOLVED] How to create formula based on the previous cell values in order
    By dedark05 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 03-29-2016, 12:13 AM
  3. Formula based on more than 240 of previous cell values
    By dedark05 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-28-2016, 10:40 PM
  4. [SOLVED] for range of cell = n, calculate sum of cell + n-1 previous cell
    By TNLNYC in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 07-02-2013, 10:20 PM
  5. Replies: 8
    Last Post: 07-16-2012, 08:21 AM
  6. Macro to auto populate the destination cell based on the values of the previous cell
    By Avinash Kumar in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-05-2009, 02:06 AM
  7. Calculate using previous cell with value greater than 0
    By jfg733 in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 07-20-2009, 12:44 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