Thread: Adding in Excel
View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default Adding in Excel

Another option.

Insert a helper column (say column A).
Put R, OT, R, OT, R, OT, ... down that column.

Then you can use a formula like:

=sumproduct(--(a1:a20="R"),(b1:b20))

Adjust the ranges to match--but you can't use whole columns.

=sumproduct() likes to work with numbers. The -- stuff changes trues and falses
to 1's and 0's.

Bob Phillips explains =sumproduct() in much more detail he
http://www.xldynamic.com/source/xld.SUMPRODUCT.html

And J.E. McGimpsey has some notes at:
http://mcgimpsey.com/excel/formulae/doubleneg.html

What's nice about this formula is that if you insert a row, you don't break the
formula. (When you add those Vacation hours and Sick hours and ....)

Ron wrote:

I have a time sheet. One row has the total number of Regular hours worked in
7 days. The next row has the total number of Overtime hours worked in those 7
days, the next row regular hours, the next overtime hours, and so on for 5
rows down. At the bottom of the sheet I need to add only the Regular hours in
one cell and I need the total Overtime hours in another cell. So I need a
formula that will add every other row, or every other number in the same
column.


--

Dave Peterson