Counting contents for Saturday dates within a range

E

Enz

I am trying to find all Saturdays within a range(on row 14), and if a
Saturday is detected, then I would like to add the values in the
corresponding row for the Saturday only dates(available in row 16).
After going through the date range, and the total sum is zero, then I
would like to return false. I also am trying to avoid doing this via
a macro as it should be automatically re-calculated if a cell changes.

Currently I have the cell formatted as follows that will provide a
true or false response, if any Saturday is detected with values in the
corresponding row. I created an IsSaturday function, that seems to be
returning #value. The result is that the formula always produces the
result of false.

=IF(SUMIF($C$14:$AG$14,IsSaturday(),C16:AG16)<>0, TRUE, FALSE)

Below is the function I have coded:

Public Function IsSaturday(x As Date) As Boolean

If Weekday(x) = 7 Then
IsSaturday = True
Else
IsSaturday = False
End Function

Is there something I am missing here, or can it be done a better way?

Thanks & regards,
Enzo
 
D

Dave Peterson

How about:

=SUMPRODUCT(--(WEEKDAY($C$14:$AG$14)=7),--($C$16:$AG$16<>0))>0

(I added $ to the stuff on row 16)

(Your udf would have to be rewritten to process a range of dates and return an
array of 1/0's or true/falses.)
 
E

Enz

How about:

=SUMPRODUCT(--(WEEKDAY($C$14:$AG$14)=7),--($C$16:$AG$16<>0))>0

(I added $ to the stuff on row 16)

(Your udf would have to be rewritten to process a range of dates and return an
array of 1/0's or true/falses.)













--

Dave Peterson- Hide quoted text -

- Show quoted text -

This does not seem to work, as the weekday works on a date as opposed
to a range of dates. I will have a look at what I might be able to do
with SUMPRODUCT or other functions. thanks,
 
D

Dave Peterson

You sure?

I'd try it once more.
This does not seem to work, as the weekday works on a date as opposed
to a range of dates. I will have a look at what I might be able to do
with SUMPRODUCT or other functions. thanks,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top