Forum Discussion

Templar70's avatar
Templar70
Copper Contributor
Jun 10, 2020
Solved

Sum of Range based on numbers in a different row

Hi, I would appreciate any help I can receive on this spreadsheet, which is being used for tracking employee absence.  I am trying to sum the total of a range.(the sum of the hours taken in the month).  This is for an employee who is working a flexible schedule and is not working the same amount of hours each day.  The issue is if the employee is off for the full day there is an X in the field.  That X is represented by a value in the row directly above it; each day in the month is given a value.  If the employee is off for only a partial work day, the number of hours is entered into the field instead of the X.  I have attached a sample of the spreadsheet, which should help better explain what I am trying to accomplish.  Thank you.

7 Replies

  • Detlef_Lewin's avatar
    Detlef_Lewin
    Silver Contributor

    Templar70 

    =SUM((B5:AF5="X")*(B$4:AF$4),B5:AF5)

    or for older versions of Excel:

    =SUMPRODUCT((B5:AF5="X")*(B$4:AF$4),B5:AF5)
    • Jos_Woolley's avatar
      Jos_Woolley
      Iron Contributor

      Detlef_Lewin 

       

      I think you need to check your second formula with SUMPRODUCT, which does not give correct results in any version of Excel.

       

      Regards

    • Templar70's avatar
      Templar70
      Copper Contributor

      Detlef_Lewin 

      This is exactly what I needed.  I'm using Office 365, so the first formula works perfectly.  Thank you so much!!

Resources