Way to write a sum without repeating the same word?

mortgageman

Well-known Member
Joined
Jun 30, 2005
Messages
2,015
I am wondering if there is a better way to write the following formula (i.e. instead of repeating the "Absent" 20 times - which is what I am going to have to do, and then do it again for "Late")

Any help would be appreciated here.

Thank you,

Gene Klein

Code:
=--(B2="Absent")+--(D2="Absent")+--(F2="Absent")+--(H2="Absent")+--(J2="Absent")
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Is there a particular reason why you skip a column each time?

A countif formula would be much more interesting in my opinion.
 
Upvote 0
Stick the word "Absent" in a cell somewhere and use the cell reference?
 
Upvote 0
Wigi - I "skip" columns because other stuff (like tests) happens in between the dates. I would rather not restructure the spreadsheet, but if I have to (so as to use countif's limitations) I will. I am hoping for a solution that has Excel accomodate me and not the other way around.

Ruddles - I don't follow what you mean. Can you be more specific?

Gene Klein
 
Upvote 0
I am wondering if there is a better way to write the following formula (i.e. instead of repeating the "Absent" 20 times - which is what I am going to have to do, and then do it again for "Late")

Any help would be appreciated here.

Thank you,

Gene Klein

Code:
=--(B2="Absent")+--(D2="Absent")+--(F2="Absent")+--(H2="Absent")+--(J2="Absent")
In your current formula there's no need for the double unary.

=(B2="Absent")+(D2="Absent")+(F2="Absent")+(H2="Absent")+(J2="Absent")

That's fine if the number of cells involved is not a lot. You wouldn't want to do that with 100 cells!

If the cells between the target cells do not contain the the word absent then you can just use a COUNTIF with a contiguous range. Like this:

=COUNTIF(B2:J2,"absent")

If the cells between might contain the criteria to be counted for and there are a lot cells involved then you can use something like this:

=SUMPRODUCT(--(MOD(COLUMN(B2:J2)-COLUMN(B2),2)=0),--(B2:J2="absent"))
 
Last edited:
Upvote 0
In your current formula there's no need for the double unary.

=(B2="Absent")+(D2="Absent")+(F2="Absent")+(H2="Absent")+(J2="Absent")

That's fine if the number of cells involved is not a lot. You wouldn't want to do that with 100 cells!

If the cells between the target cells do not contain the the word absent then you can just use a COUNTIF with a contiguous range. Like this:

=COUNTIF(B2:J2,"absent")

If the cells between might contain the criteria to be counted for and there are a lot cells involved then you can use something like this:

=SUMPRODUCT(--(MOD(COLUMN(B2:J2)-COLUMN(B2),2)=0),--(B2:J2="absent"))

I tried your SUMPRODUCT formula Biff (Thank you BTW) but the result was 1, even though there were two "Absent"s (both of which I wanted to count) in the range.

Gene Klein
 
Upvote 0
I tried your SUMPRODUCT formula Biff (Thank you BTW) but the result was 1, even though there were two "Absent"s (both of which I wanted to count) in the range.

Gene Klein

I just realized: If I am not worried about "false positives" in the range, I can just use countif.

Gene Klein
 
Upvote 0
Here's a regular formula alternative that tests every other column (B2, D2, etc) for the word "absent" and returns the count of matches:
=SUM(COUNTIF(OFFSET(B2,,{0,2,4,6,8}),"absent"))

Note: The OFFSET function is volatile and calculates whenever any cell in the workbook calculates. But, when used sparingly and judiciously, it can be very useful.

Does that help?
 
Upvote 0
Here's a regular formula alternative that tests every other column (B2, D2, etc) for the word "absent" and returns the count of matches:
=SUM(COUNTIF(OFFSET(B2,,{0,2,4,6,8}),"absent"))

Note: The OFFSET function is volatile and calculates whenever any cell in the workbook calculates. But, when used sparingly and judiciously, it can be very useful.

Does that help?
The offset wouldn't help here since the "space" between my dates is not regular. However, like I said above, none of the columns inbetween my dates would have anything close to "Absent" or "Late" etc, so the plain vanilla countif will work perfectly. Thank you to all who posted.

Gene Klein
 
Upvote 0

Forum statistics

Threads
1,224,616
Messages
6,179,909
Members
452,949
Latest member
beartooth91

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top