Adding a condition to VBA CountIF
On 26/10/2011 2:07 AM, Rick Rothstein wrote:
Layout
E G H I J
Name Hrs Breaks PreOps Signed
Jack OK NO OK OK
Pete NO OK OK NO
John OK OK OK OK
The desired wksTarget result would be:
E G H I J
Name Hrs Breaks PreOps Signed
Jack 0 1 0 0
Pete 1 0 0 1
John 0 0 0 0
I may be missing something, but for what I think you described, why not
(in code) just copy the OK/NO table to the desired wksTarget location
and then use the range's Replace method twice on the entire range, once
to replace OK with 0 and the second time to replace NO with 1?
Rick Rothstein (MVP - Excel)
Thanks Rick
Looking at it in another way is to use Sumproduct(), the downside is
that would mean I would have to nest each drivers name and apply the
formula to each driver and for each column.
=SUMPRODUCT(--(Summary!"$E5:$E15000"="Jack")--(Summary!$G$5:$G15000"="NO"))
That means lots of work plus if/when any new drivers are added it also
then has to get formulas added also, this code was a great shortcut.
I will keep plugging away at it.
Thx again.
Mick
|