Countif on horizontal data (in a row)

Gazzat

New Member
Joined
Dec 5, 2021
Messages
4
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Hi,
Please see the sheet below and the formula that has returned a result of "0" in cell K5.
The image represents a small sample of a 25,000 row spreadsheet. For each row, I would like column K to count the number of cells from B to J in the same row (in this case row 5) that begin with a "K". The result in K5 should read "3", not "0".

Please help- 6 hours of trying different solutions and searching the boards has not lead to an answer yeto_O
Thanks!!!
Gazzat

Capture.PNG
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Hi Gazzat,

It appears the cells have some other character (maybe a space?) before the "K".

You can use =CODE(cell) to check what that first character is. 32 would be a space.

If you don't care about that character you can use =COUNTIF(B5:H5,"?K*") to wildcard around it.
 
Upvote 0
I suspect the problem is in your data. Could you have leading spaces in those strings? Try this first:

Excel Formula:
=COUNTIF(B5:J5," K*")

then if that doesn't work try this one

Excel Formula:
=COUNTIF(B5:J5,"*K*")

If either of those work, you have a leading space or other unprintable character in the beginning of those strings.
 
Upvote 0
Solution
Looking at your screenshot I am pretty sure you have leading spaces in your data except for column B.
 
Upvote 0
Looking at your screenshot I am pretty sure you have leading spaces in your data except for column B.
Dear Jeff,
Your rapid response was a lifesaver :) , displaying Wes Montgomeryesque fluidity and precision. =COUNTIF(B5:J5,"*K*") was the winner.
Thank you so much,
Gaz
 
Upvote 0
Hi Gazzat,

It appears the cells have some other character (maybe a space?) before the "K".

You can use =CODE(cell) to check what that first character is. 32 would be a space.

If you don't care about that character you can use =COUNTIF(B5:H5,"?K*") to wildcard around it.
Thanks Toadstool!!- =COUNTIF(B5:H5,"*K*") worked.
 
Upvote 0

Forum statistics

Threads
1,214,812
Messages
6,121,704
Members
449,048
Latest member
81jamesacct

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