Report

If a cell contains any text then add a value (with dates) [Solved]

Ask a question ryannordgren 7Posts Saturday March 4, 2017Registration date March 7, 2017 Last seen - Last answered on Mar 7, 2017 at 07:01 PM by ryannordgren
I am looking for help with a formula that will allow me to add up the number of times a certain date is a Monday. I am using =COUNTIF(A1:A30,"*Monday*"). The issue that I have is I am entering dates like 3/6/17 and have the formatting set to show it as "Monday, March 7, 2017." Because Monday was not typed into the cell, it doesn't count it. Is there a way to get the number of Mondays counted?? Please help.
Helpful
+1
plus moins
ryannordgren, Good evening.

Try to use:

=SUMPRODUCT(--(WEEKDAY(A1:A30, 2)=1))

Is that what you want?
I hope it helps.
--
Belo Horizonte, Brasil.
Marcílio Lobão
Was this answer helpful?  
ryannordgren 7Posts Saturday March 4, 2017Registration date March 7, 2017 Last seen - Mar 4, 2017 at 11:32 PM
Yes, Thank you! This works.
Reply
ryannordgren 7Posts Saturday March 4, 2017Registration date March 7, 2017 Last seen - Mar 5, 2017 at 12:04 AM
One more question, if you have the time. I can get this to work now for each day of the week except for Saturday. Any idea how to get it to count Saturdays using this same formula?
Reply
Leave a comment
Helpful
+1
plus moins
ryannordgren, Good evening.

"...Any idea how to get it to count Saturdays using this same formula?..."

Look at this:

WEEKDAY( Serial_number, Return_type)

The WEEKDAY function syntax has the following arguments:

Serial_number:
A sequential number that represents the date of the day you are trying to find. Dates should be entered by using the DATE function, or as results of other formulas or functions. For example, use DATE(2008,5,23) for the 23rd day of May, 2008. Problems can occur if dates are entered as text.

Return_type:
A number that determines the type of return value.

2 --> Numbers 1 (Monday) through 7 (Sunday).

then...
1 --> Monday
2 --> Tuesday
3 --> Wednesday
4 --> Thursday
5 --> Friday
6 --> Saturday
7 --> Sunday

In the suggested formula, we compare the number of the day of the week to the value 1, which means Monday.
=SUMPRODUCT(--(WEEKDAY(A1:A30, 2)= 1 ))

Simply replace these values to get the count for each day of the week you want.

I hope it helps.
--
Belo Horizonte, Brasil.
Marcílio Lobão
Was this answer helpful?  
ryannordgren 7Posts Saturday March 4, 2017Registration date March 7, 2017 Last seen - Mar 7, 2017 at 03:14 PM
I appreciate your help. This formula:
=SUMPRODUCT(--(WEEKDAY(A1:A30, 2)= 1 ))
works for every day of the week except Saturday. For some reason when I enter the formula: =SUMPRODUCT(--(WEEKDAY(A3:A200, 2)= 6 )) - for Saturday, it shows the value "198" with no values in the A column!? For every date I add in the A column, it subtracts another 1 from the 198. For example if I add a date range comprising Sunday through Saturday - 7 lines - it will read "192."

The formulas counting for every other day of the week read "1" for this same formula. It just doesn't want to work for Saturday for some reason. I don't know why it is subtracting when the same formula using every other day of the week (1,2,3,4,5,7) works correctly, adding a value of 1.

Any ideas friend?
Reply
x- Mar 7, 2017 at 05:56 PM
Try this one. It checks for a blank in the cell.

=SUMPRODUCT(--(A3:A200<>""),--(WEEKDAY(A3:A200,2)=6))

This issue of blanks being interpreted as Saturdays has been around for a years now.
Reply
ryannordgren 7Posts Saturday March 4, 2017Registration date March 7, 2017 Last seen - Mar 7, 2017 at 07:01 PM
Most excellent! that works perfectly!
Reply
Leave a comment

Member requests are more likely to be responded to.

Members can monitor the statuses of their requests from their account pages.

A CCM membership gives you access to additional options.

Not a member yet?

Sign up now. It takes less than a minute and is completely free!