Help with countif

M

Mike

Ok here is my code.

=COUNTIF('Crash data'!$K$2:$K$462,">=12.33")-COUNTIF('Crash
data'!$K$2:$K$462,">12.43")

This works fine. Problem that I am having is when I change the 12.33 (for
example) to a cell reference (say C5) and I change 12.43 to a reference it
does not work.

Any ideas?

Thanks.
 
B

Bob Phillips

=COUNTIF('Crash data'!$K$2:$K$462,">="&C5)-COUNTIF('Crash
data'!$K$2:$K$462,">"&C6)


--

HTH

RP
(remove nothere from the email address if mailing direct)
 
J

JulieD

Hi Mike

change the formula to

=COUNTIF('Crash data'!$K$2:$K$462,">="&C5)-COUNTIF('Crash
data'!$K$2:$K$462,">"&C6)

Cheers
JulieD
 
P

Peo Sjoblom

Try

=COUNTIF('Crash data'!$K$2:$K$462,">="&C5)-COUNTIF('Crash
data'!$K$2:$K$462,">"&C6)

Regards,

Peo Sjoblom
 
M

Mike

This method worked out, thanks to all.

Next step. Now that this is working I also want sort by a year.

So if I sort all the items in this range, then I want to sort by a year?

Do I use a Count(If + the above function?

Thanks.
 
J

JulieD

Hi Mike

i'm guessing you're not really wanting to "sort" as in data / sort ... but
add an additional criteria to your statement. If this is the case you'll
need to use the SUMPRODUCT function, e.g.

=SUMPRODUCT(--('Crash data'!$K$2:$K$462>=C5),--('Crash
data'!$K$2:$K$462<C6),--(YEAR('Crash data'!H2:H159)=2004))

Cheers
JulieD
 
P

Peo Sjoblom

aIf you want to sore that range by year you can use a help column and a
formula like

=YEAR(K2)

copy down to K462 and select both columns and sort by the help column,
if you meant that you want to apply the constraints from your countif AND a
particular year you can use


=SUMPRODUCT(--('Crash data'!$K$2:$K$462>=C5),--('Crash
data'!$K$2:$K$462<=C6),--(YEAR('Crash data'!$K$2:$K$462)=2004))


Regards,

Peo Sjoblom
 
M

Mike

What does the -- in between functions mean?

JulieD said:
Hi Mike

i'm guessing you're not really wanting to "sort" as in data / sort ... but
add an additional criteria to your statement. If this is the case you'll
need to use the SUMPRODUCT function, e.g.

=SUMPRODUCT(--('Crash data'!$K$2:$K$462>=C5),--('Crash
data'!$K$2:$K$462<C6),--(YEAR('Crash data'!H2:H159)=2004))

Cheers
JulieD
 

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