=COUNTA help

Scottsdale

New Member
Joined
Aug 22, 2024
Messages
3
Office Version
  1. 2016
Platform
  1. Windows
I have 6 cells using columns (K2 to P2) that may contain a number followed by a one letter. Eg. 3G or maybe 16B. This number/letter is a child's age and gender: G = girl, B = boy. I need one formula to count the cells if the number is less than 13 and another formula to count the cells if the number is greater than 12.

I've tried using these COUNTA formulas:
=COUNTA(K2:P2;"<13")
=COUNTA(K2:P2;">12")
...but if 3 cells contain data, it returns a count of 4 cells, which is wrong.

Any suggestions? Splitting the age/gender into two columns (though easy) is not an option.

Cheers,
Scott
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Hi,

You can either try using a customer format where G & B are just formatted i.e it stays as a number.

However, if you want to have it as a string I would simply add a helper column for the count using:

Excel Formula:
=IFERROR(VALUE(LEFT(K1,LEN(K1)-1)),"n.a.")

Then use the counts:
Bigger equal 13:
Excel Formula:
=COUNTIFS(K2:P2,">=13")
Less then 13:
Excel Formula:
=COUNTIFS(K2:P2,"<13")



countifs.png
 
Upvote 0
Hi Scottsdale,
use this one after entering just press
CTRL+SHIFT+ENTER

=SUM(IF(ISNUMBER(VALUE(LEFT(K2:P2,2))),IF(VALUE(LEFT(K2:P2,2))<13,1,0),IF(VALUE(LEFT(K2:P2,1))<13,1,0)))
=SUM(IF(ISNUMBER(VALUE(LEFT(K2:P2,2))),IF(VALUE(LEFT(K2:P2,2))>12,1,0),IF(VALUE(LEFT(K2:P2,1))>12,1,0)))
 
Upvote 0
Hi,

You can either try using a customer format where G & B are just formatted i.e it stays as a number.

However, if you want to have it as a string I would simply add a helper column for the count using:

Excel Formula:
=IFERROR(VALUE(LEFT(K1,LEN(K1)-1)),"n.a.")

Then use the counts:
Bigger equal 13:
Excel Formula:
=COUNTIFS(K2:P2,">=13")
Less then 13:
Excel Formula:
=COUNTIFS(K2:P2,"<13")



View attachment 115807
Hi....this worked! Cheers for your quick reply!
 
Last edited by a moderator:
Upvote 0
Hi Scottsdale,
use this one after entering just press
CTRL+SHIFT+ENTER

=SUM(IF(ISNUMBER(VALUE(LEFT(K2:P2,2))),IF(VALUE(LEFT(K2:P2,2))<13,1,0),IF(VALUE(LEFT(K2:P2,1))<13,1,0)))
=SUM(IF(ISNUMBER(VALUE(LEFT(K2:P2,2))),IF(VALUE(LEFT(K2:P2,2))>12,1,0),IF(VALUE(LEFT(K2:P2,1))>12,1,0)))
Hi...thx for your reply too! Worked well. Cheers.
 
Upvote 0
Hi...thx for your reply too! Worked well. Cheers.
I have removed the 'Mark as solution' from that post as it isn't the solution.
From your comments it appears there may be two posts with solutions. If that is the case then you can mark one of those with the 'Mark as solution' (preferred) or else leave the thread without such a mark (less preferred if there is actually a solution).
 
Upvote 0

Forum statistics

Threads
1,223,705
Messages
6,173,996
Members
452,542
Latest member
Bricklin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top