Counting characters within a cell

jacmorgra

New Member
Joined
Jun 9, 2021
Messages
3
Office Version
  1. 2016
Platform
  1. Windows
Hi, I am trying to count the number of spaces in a cell. I have a number codes of varying length in a cell which are separated by spaces - if I can count the spaces I will know how many codes there are.... I have been using text to columns with space as a delimiter but this is too cumbersome and wondered if the spaces could just be counted instead. Thanks in advance
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Welcome to the MrExcel board!

A formula like this should tell you how many codes in A1
Excel Formula:
=LEN(A1)-LEN(SUBSTITUTE(A1," ",""))+1
 
Upvote 0
Solution
Hi & welcome to MrExcel.
How about
Excel Formula:
=LEN(A2)-LEN(SUBSTITUTE(A2," ",""))
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0
Welcome to the MrExcel board!

A formula like this should tell you how many codes in A1
Excel Formula:
=LEN(A1)-LEN(SUBSTITUTE(A1," ",""))+1

Hello Peter,

What is the reason for putting +1 at the end?
 
Upvote 0
Hello Peter,

What is the reason for putting +1 at the end?
To correctly count the number of codes. eg If there are 2 spaces (what the LEN parts of the formula counts) then there must be 3 codes.
 
Upvote 0

Forum statistics

Threads
1,214,652
Messages
6,120,747
Members
448,989
Latest member
mariah3

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