Link to home
Start Free TrialLog in
Avatar of Steve_Brady
Steve_BradyFlag for United States of America

asked on

How do you put =LEFT() inside =COUNTIF() in Excel?

Hello,

How do you correctly put a =LEFT() function inside of a =COUNTIF() function?

For example, here's a formula I just tried (which obviously does not work):

=COUNTIF(LEFT(L4:L33963,2),L2)

My objective is to determine how many of the entries in the range begin with the two characters:  "##" (i.e. not variables but two number signs) and have the result display in L3.  Therefore, I entered "##" in L2 and the above formula in L3.  

In other words, I don't want to count the cells whose complete entries are the same as L3 but only those whose first two characters are the same.  To do that, it seems like there should be an equal sign in there somewhere saying, "if the first two characters in a given row equal the value in L2 then count that row" but I can't determine where it would go.

Sometimes these formulas just fall right into place and other times it seems as though there is a 12 inch block wall (full of grout) standing in the way!  :p

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Patrick Matthews
Patrick Matthews
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
We were taught to split complex problems in excel into smaller parts... I've never felt like I would run out of space in a spreadsheet. Try putting the left function in another column and then referencing THAT column with your countif function. If it annoys you, you can always hide the column so you don't have to look at it. Then it will work, and it will not have the weakness of the wildcard method as explained above.

Thanks to barryhoudini for some great information. I never knew why certain things didn't work, I always just found work arounds. Very cool.
You could also convert it to an array formula by confirming entry with Shift + Ctrl + Enter.

There are numerous trains of thought about array formulas, probably worth avoiding where there is another option.

Thanks
Rob H
Avatar of Steve_Brady

ASKER

Multiple helpful responses!  Thanks

>>Thanks to barryhoudini for some great information....Very cool.

Not meant to embarrass him but FYI, Barry's answers are always accurate, always straightforward, always easy to follow and understand, and always include "great information."  He is a good one to follow around!

Afterthought:  perhaps "always" is a tad bit too strong -- I know Barry would say so -- so perhaps we should change them to "almost always" but if we do, note that the "tad" is a very small one indeed!  :)
Thanks