Jump to content

EXCEL : Formula help request


Recommended Posts

Posted

Hello All

I need help writing a a formula in MS Excel 2003.

post-29668-1141169265_thumb.jpg

I want the cell "J1" to display how many "P" letter in the line from "B1" to "I1"

Thanks !

-army


Posted (edited)

write formula in J1

=COUNTIF(B1:I1, "p")

To count p, which is a text value, enclose in quotes

Edited by clavicle
Posted

Is there any way to leave the cell blank or to display 0 when the result of the formula equal #DIV/0! ?????

-army

Posted

can I simplify this formula: =COUNTIF(G3:GG3;"p")/(COUNTIF(G3:GG3;"p")+COUNTIF(G3:GG3;"n")+COUNTIF(G3:GG3;"a"))

it says: Give me the number of P and divide it by the total number of time the letter P,A,N are shown

Posted (edited)

It probably won't be possible, because you can put 0 where there is error as #DIV/0! is not equal to 0

Getting blank is also not possible, becasue excel is calculating it as an error, otherwise, conditional formating is the solution for any error free value, say 0.

Edited by clavicle
Posted
=COUNTIF(G3:GG3;"p")/(COUNTIF(G3:GG3;"p")+COUNTIF(G3:GG3;"n")+COUNTIF(G3:GG3;"a")
change to
=COUNTIF(G3:GG3;"p")/(COUNTIF(G3:GG3;"p")+COUNTIF(G3:GG3;"n")+COUNTIF(G3:GG3;"a"))

You are missing out closing brace to make whole denominator one value

post-13315-1141203575_thumb.jpg

Posted

Actually it is possible by enclosing the formula in an IF statement, using the ISERR function:

This will give 0 if an error is the result:

=IF(ISERR(COUNTIF(G3:GG3;"p")/(COUNTIF(G3:GG3;"p")+COUNTIF(G3:GG3;"n")+COUNTIF(G3:GG3;"a")));0;COUNTIF(G3:GG3;"p")/(COUNTIF(G3:GG3;"p")+COUNTIF(G3:GG3;"n")+COUNTIF(G3:GG3;"a")))
This will give blank if an error is the result:
=IF(ISERR(COUNTIF(G3:GG3;"p")/(COUNTIF(G3:GG3;"p")+COUNTIF(G3:GG3;"n")+COUNTIF(G3:GG3;"a")));"";COUNTIF(G3:GG3;"p")/(COUNTIF(G3:GG3;"p")+COUNTIF(G3:GG3;"n")+COUNTIF(G3:GG3;"a")))

This will prevent ONLY #DIV/0!:

=IF((COUNTIF(G3:GG3;"p")+COUNTIF(G3:GG3;"n")+COUNTIF(G3:GG3;"a"))=0;"";COUNTIF(G3:GG3;"p")/(COUNTIF(G3:GG3;"p")+COUNTIF(G3:GG3;"n")+COUNTIF(G3:GG3;"a")))

I am sure you get the idea...

jaclaz

Posted

THANKS a lot guys !

I'm getting really close to my goal. Last thing I have to know is a bit more complicated.

The formula you gave to me is all about calculating the % of time my soldiers where present during the year. But there is mendatory days and non mendatory days.

So I would like to formula to COUNTIF(G3:GG3;"p") only when the cell pattern is green. Is that possible ???

post-29668-1141261372_thumb.jpg

I'm now entering a PF when it's a non mendatory day but it will be very appreciated if I can use the formula with formating

-Army

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...