+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 18

Thread: looking for help with IF statement to add multiple cells

  1. #1
    Registered User
    Join Date
    01-20-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2007
    Posts
    33

    looking for help with IF statement to add multiple cells

    I have a workbook containing multiple sheets with a cell with a drop list of 2 choices of banks. The adjacent cell contains a dollar amount. The last sheet is to add up the dollars amounts for the first bank in 1 cell and add up the dollar amounts of the 2nd bank in another cell. I just can't figure how to add the cells when using an IF statement. But perhaps there is a better way to do it. I have attached a sheet with example.banks.xlsx

    Many thanks in advance for your help and suggestions.
    Last edited by lisach; 02-06-2012 at 10:16 PM.

  2. #2
    Forum Guru JBeaucaire's Avatar
    Join Date
    03-21-2008
    Location
    Bakersfield, CA
    MS-Off Ver
    2010
    Posts
    19,222

    Re: looking for help with IF statement to add multiple cells

    Put this formula in E3, then copy down:

    =SUM(SUMIF(INDIRECT("Sheet"&{1,2,3}&"!C4"),"="&D3,INDIRECT("Sheet"&{1,2,3}&"!D4")))
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    “None of us is as good as all of us” - Ray Kroc
    “Actually, I *am* a rocket scientist.” - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    01-20-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2007
    Posts
    33

    Re: looking for help with IF statement to add multiple cells

    That works incredibly well! Now since my attached sheet is just an example I need some further information (if you please?) I am trying to understand the syntax you used to reference the sheet names. My sample is using generic sheet names. My live workbook contains sheets: Mon, Tues, Wed, Thurs, Fri, Sat.

    Could you explain the syntax to me so that I can apply it?

  4. #4
    Registered User
    Join Date
    01-20-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2007
    Posts
    33

    Re: looking for help with IF statement to add multiple cells

    Oh and one more issue.... I know that in a formula if the name of a referenced sheet is changed the change will carry over into the formula. But this one doesn't appear to behave the same way. I ask because this is in a template that is saved under different names and the sheet names I cited above are appended with the date ie.... Mon 1-1, Tues 1-2, etc.... I know I should have mentioned this to begin with, I just didn't think it was important until I saw the effect within your solution.

  5. #5
    Forum Guru JBeaucaire's Avatar
    Join Date
    03-21-2008
    Location
    Bakersfield, CA
    MS-Off Ver
    2010
    Posts
    19,222

    Re: looking for help with IF statement to add multiple cells

    It's an array formula, the example I gave you actually creates 3 separate formulas for each Sheet1, Sheet2 and Sheet3. That works because it matched your example.

    Your sample workbooks need to match the working environment so as to not waste time with inaccurate suggestions. If your sheet names are not related, then I would employ a different method.

    Have you dumbed the whole question down too far? Are there more cells to consider? More criteria? Working with your fuller workbook may save you (and us) time.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    “None of us is as good as all of us” - Ray Kroc
    “Actually, I *am* a rocket scientist.” - JB (little ones count!)

  6. #6
    Registered User
    Join Date
    01-20-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2007
    Posts
    33

    Re: looking for help with IF statement to add multiple cells

    I do appreciate your question. My enormous apologies. I don't do arrays and thus truly didn't understand the impact of changing the sheet names. Changing the sheet names has not been an issue for me before.

    The cells I am working on are in sheet WEEKLY SUMMARY cells E6 & E7. Referencing the daily sheets Cells F21 & G21

    Weekly Template for Business.xlsx

  7. #7
    Forum Guru JBeaucaire's Avatar
    Join Date
    03-21-2008
    Location
    Bakersfield, CA
    MS-Off Ver
    2010
    Posts
    19,222

    Re: looking for help with IF statement to add multiple cells

    There is an array of sheetnames off to the right in column L. Those are used to create a named range MySheets, and that is then used in the array formula entered into E6, then copied down. As an array, you confirm any edits by pressing CTRL-SHIFT-ENTER to reactivate the array, and you will see the braces { } appear around the formula to indicate an active array.

    I also corrected all the formulas in your other columns to properly do a 3D sum of the same cell across the sequential sheets, like =SUM(Mon:Fri!$B4),
    Most of the formulas on the Summary sheet were updated in similar ways.
    Attached Files Attached Files
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    “None of us is as good as all of us” - Ray Kroc
    “Actually, I *am* a rocket scientist.” - JB (little ones count!)

  8. #8
    Registered User
    Join Date
    01-20-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2007
    Posts
    33

    Re: looking for help with IF statement to add multiple cells

    Thank-you Jerry, I really appreciate all the help. Apologies for not replying sooner, was gone for the weekend. I need to read up a little on this, I want to understand how this works. And it CERTAINLY DOES WORK! You just gave me a lot of studying to do! Can't thank-you enough.

  9. #9
    Forum Guru JBeaucaire's Avatar
    Join Date
    03-21-2008
    Location
    Bakersfield, CA
    MS-Off Ver
    2010
    Posts
    19,222

    Re: looking for help with IF statement to add multiple cells

    Glad to help, I'm sure you'll figure it out. Post back here if you have clarification questions.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    “None of us is as good as all of us” - Ray Kroc
    “Actually, I *am* a rocket scientist.” - JB (little ones count!)

  10. #10
    Registered User
    Join Date
    01-20-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2007
    Posts
    33

    Re: looking for help with IF statement to add multiple cells

    Hi. its me again. Got a problem with the formula you wrote and i wasn't able to figure out how to fix it. I attached the sheet with populated data. The formulas in cells E6 and E7 on the weekly Summary sheet aren't adding up correctly. Could you please look at it and see? thanks

    Copy of Weekly Template for Business-1.xlsx

    I populated cells in Fri and Sat sheets only for testing. Cells B21 and G21. Let me know if I didn't clarify enough.

  11. #11
    Forum Guru JBeaucaire's Avatar
    Join Date
    03-21-2008
    Location
    Bakersfield, CA
    MS-Off Ver
    2010
    Posts
    19,222

    Re: looking for help with IF statement to add multiple cells

    Look at the formula:

    =SUM(SUMIF(INDIRECT(MySheets&"!F21"), "="&D6, INDIRECT(MySheets&"!G21")))

    In this structure, F21 is the cell being "checked" on each sheet, and G21 is the values being added.

    Seems to me like you want A21 and B21 in the new structure.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    “None of us is as good as all of us” - Ray Kroc
    “Actually, I *am* a rocket scientist.” - JB (little ones count!)

  12. #12
    Registered User
    Join Date
    01-20-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2007
    Posts
    33

    Re: looking for help with IF statement to add multiple cells

    Hi Jerry,
    Thanks for taking a look at this. Sorry for the delay. Am working at the moment in location where I have no internet connectivity during the day. (ugg..)
    Its not that there is a new structure. The sheet is exactly the same. The thing is, on each daily sheet there are 2 locations for deposits. One for the Self Service revenue (CELL B21) and the one for the Wash revenue (CELL G21). Accounts exist at 2 different banks. And each type of deposit, SS or W, could go to either bank (thus the drop list in cell A21 and F21. So this summary sheet is to go back and look at the daily sheets and total the amount of deposits that went to each bank.

    So on the summary sheet:
    Cell E6 should go back to the each daily sheet looking at cells A21 and F21..... if either = "Wells Fargo" add and total Cell B21 and G21 respectively.
    Cell E7 should look at A21 and F21.... if either = "Community1" add B21 and G21 respectively.
    Thereby giving a total of all deposits to 1st bank in Cell E6 and all deposits to 2nd bank in cell E7.

    Perhaps i didn't make myself very clear in the beginning. My apologies in advance is so.

  13. #13
    Forum Guru JBeaucaire's Avatar
    Join Date
    03-21-2008
    Location
    Bakersfield, CA
    MS-Off Ver
    2010
    Posts
    19,222

    Re: looking for help with IF statement to add multiple cells

    So, put two versions of the formula in the same cell with a + between them... should be all you need.


    =SUM(SUMIF(INDIRECT(MySheets&"!F21"), "="&D6, INDIRECT(MySheets&"!G21"))) +
    SUM(SUMIF(INDIRECT(MySheets&"!A21"), "="&D6, INDIRECT(MySheets&"!B21")))
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    “None of us is as good as all of us” - Ray Kroc
    “Actually, I *am* a rocket scientist.” - JB (little ones count!)

  14. #14
    Registered User
    Join Date
    01-20-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2007
    Posts
    33

    Re: looking for help with IF statement to add multiple cells

    You would think so but something just doesn't work. Sorry to be such a pain.... I copied that very formula and pasted it into Cell E6 on the summary worksheet and it didn't pick up the wells fargo deposit on Friday. I copied it and pasted it into Cell E7, changed the criteria to D7 and it gives my a value error.
    Copy of Weekly Template for Business-2.xlsx What did I do wrong?

  15. #15
    Forum Guru JBeaucaire's Avatar
    Join Date
    03-21-2008
    Location
    Bakersfield, CA
    MS-Off Ver
    2010
    Posts
    19,222

    Re: looking for help with IF statement to add multiple cells

    You forgot that these are array formulas. When you're editing, you confirm those changes by pressing Ctrl-Shfit-Enter to reactivate the arrays, else it simply doesn't work.


    You'll know the array is active when you see the curly braces { } appear around your formulas.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    “None of us is as good as all of us” - Ray Kroc
    “Actually, I *am* a rocket scientist.” - JB (little ones count!)

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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.2.0