+ Reply to Thread
Results 1 to 8 of 8

How to add up cells in a row based on criteria in neighbouring cell

  1. #1
    Registered User
    Join Date
    08-30-2013
    Location
    Caribbean
    MS-Off Ver
    Excel 2010
    Posts
    9

    How to add up cells in a row based on criteria in neighbouring cell

    Good afternoon,

    I am trying to create a spreadsheet in which I have to add up numbers based on the value in the cell next to them. I have attached a test file so it is easier to understand:

    Here the explanation of the sheet:
    Cells F, H, J, etc. with the letter A, B, C indicate a cost center
    Cells G, I, K, etc. contain the amount of hours worked in that week
    Cells C2, D2, E2 contain multipliers for each letter (A, B, C)

    What I need now, is a formula in C5 that adds up all the hours with an "A", multiplies it with C2 + all the hours with a "B", multiplies it with D2 + all the hours with a "C", multiplies it with E2.

    How can this be done?? Any help is highly appreciated
    Attached Files Attached Files

  2. #2
    Forum Expert RobertMika's Avatar
    Join Date
    06-22-2009
    Location
    Haverhill, UK
    MS-Off Ver
    Excel 2003-13
    Posts
    1,530

    Re: How to add up cells in a row based on criteria in neighbouring cell

    =sumif(f5:ag5,c1,g5:ah5)*c2+sumif(f5:ag5,d1,g5:ah5)*e2+sumif(f5:ag5,e1,g5:ah5)*c2
    If you are http://www.excelforum.com/image.php?type=sigpic&userid=125481&dateline=1392355029happy with the results, please add to the contributor's
    reputation by clicking the reputation icon (star icon).




    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.
    To undo, select Thread Tools-> Mark thread as Unsolved.
    http://www.excelaris.co.uk

  3. #3
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2504 Win 11
    Posts
    24,687

    Re: How to add up cells in a row based on criteria in neighbouring cell

    If you rearrange your sheet to look like my Sheet2, then you can apply the Sumif formula. See the attachment.
    Attached Files Attached Files
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  4. #4
    Registered User
    Join Date
    08-30-2013
    Location
    Caribbean
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: How to add up cells in a row based on criteria in neighbouring cell

    Thank you RobertMika, that works well. I tried the Sumif, but for whatever reason it didn't work. Yours is simple but works well.

  5. #5
    Registered User
    Join Date
    08-30-2013
    Location
    Caribbean
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: How to add up cells in a row based on criteria in neighbouring cell

    Thank you alansidman, it would work, but due to the amount of data on my sheet I can't rearrange it that way. But thank you so much for your suggestion, I really appreciate your time and assistance.

  6. #6
    Forum Expert RobertMika's Avatar
    Join Date
    06-22-2009
    Location
    Haverhill, UK
    MS-Off Ver
    Excel 2003-13
    Posts
    1,530

    Re: How to add up cells in a row based on criteria in neighbouring cell

    You are welcome.
    Just small correction
    =SUMIF(F5:AG5,C1,G5:AH5)*C2+SUMIF(F5:AG5,D1,G5:AH5)*D2+SUMIF(F5:AG5,E1,G5:AH5)*E2
    or if hard coded
    =SUM(SUMIF(F5:AG5,{"A","B","C"},G5:AH5)*{0.5,0.7,1.2})


    Please add reputation to my name!

  7. #7
    Registered User
    Join Date
    08-30-2013
    Location
    Caribbean
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: How to add up cells in a row based on criteria in neighbouring cell

    RobertMika
    Thanks so much, the short version is even better. Added to your reputation!!

  8. #8
    Forum Expert RobertMika's Avatar
    Join Date
    06-22-2009
    Location
    Haverhill, UK
    MS-Off Ver
    Excel 2003-13
    Posts
    1,530

    Re: How to add up cells in a row based on criteria in neighbouring cell

    Thank you and welcome

+ 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. Fill in cells with a value based on a neighbouring column
    By ppataki in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 08-26-2014, 11:18 AM
  2. [SOLVED] Formula to autofill neighbouring cells when a value is added to another
    By 2571 in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 11-23-2012, 10:08 AM
  3. Counting cells conditional on neighbouring columns
    By BFee in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-03-2010, 02:13 AM
  4. Filling blank cells based on neighbouring column
    By ppataki in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-02-2009, 06:28 AM
  5. Copying cells to the neighbouring column in pairs along Row 1
    By shmee150 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 03-13-2009, 12:23 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