Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Mike
 
Posts: n/a
Default Help with countif

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.
  #2   Report Post  
Bob Phillips
 
Posts: n/a
Default

=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)


"Mike" wrote in message
...
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.



  #3   Report Post  
JulieD
 
Posts: n/a
Default

Hi Mike

change the formula to

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

Cheers
JulieD

"Mike" wrote in message
...
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.



  #4   Report Post  
Peo Sjoblom
 
Posts: n/a
Default

Try

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

Regards,

Peo Sjoblom


"Mike" wrote:

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.

  #5   Report Post  
Mike
 
Posts: n/a
Default

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.

"Peo Sjoblom" wrote:

Try

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

Regards,

Peo Sjoblom


"Mike" wrote:

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.



  #6   Report Post  
JulieD
 
Posts: n/a
Default

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



"Mike" wrote in message
...
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.

"Peo Sjoblom" wrote:

Try

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

Regards,

Peo Sjoblom


"Mike" wrote:

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.



  #7   Report Post  
Peo Sjoblom
 
Posts: n/a
Default

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



"Mike" wrote:

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.

"Peo Sjoblom" wrote:

Try

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

Regards,

Peo Sjoblom


"Mike" wrote:

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.

  #8   Report Post  
Mike
 
Posts: n/a
Default

What does the -- in between functions mean?

"JulieD" wrote:

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



"Mike" wrote in message
...
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.

"Peo Sjoblom" wrote:

Try

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

Regards,

Peo Sjoblom


"Mike" wrote:

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.




  #9   Report Post  
Bob Phillips
 
Posts: n/a
Default

See http://xldynamic.com/xld.SUMPRODUCT.html

--

HTH

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


"Mike" wrote in message
...
What does the -- in between functions mean?

"JulieD" wrote:

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



"Mike" wrote in message
...
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.

"Peo Sjoblom" wrote:

Try

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

Regards,

Peo Sjoblom


"Mike" wrote:

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.






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
COUNTIF text where there is more than one word in a cell Abi Excel Worksheet Functions 2 January 20th 05 03:32 AM
countif statement Russell Hampton Excel Worksheet Functions 6 December 18th 04 07:39 PM
Countif - Countif maswinney Excel Worksheet Functions 3 November 15th 04 11:06 PM
Countif, Sumif, If - help! Angel160 Excel Worksheet Functions 2 November 3rd 04 05:23 PM
countif, again Liz G Excel Worksheet Functions 2 November 1st 04 11:20 PM


All times are GMT +1. The time now is 04:54 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"