5 Ways to Count Cells that Contain Text in Microsoft Excel (2024)

Do you need to count the number of cells in a Microsoft Excel spreadsheet that contain text? There are a few ways you can do it!

You might have a mixed set of text and numerical data and need to find out how much of it is text in order to get a better sense of your dataset.

In this blog post, you’ll see all the different methods for counting cells containing text data as well as the advantages and disadvantages of each method.

Get your copy of the example workbook with the above link and follow along to learn how to count cells that contain text in Microsoft Excel!

Count Cells that Contain Text using the COUNTIF Function

The first way to count your text data is using the COUNTIF function.

Usually, COUNTIF is used when you need to count data that meets a particular criterion. However, you can use it in a more generic way to count any text.

You can use the * wildcard character to represent any text within the COUNTIF criterion input.

5 Ways to Count Cells that Contain Text in Microsoft Excel (1)
= COUNTIF ( B3:B14, "*" )

Use the above formula to count all the text values in a range. The "*" condition will count anything in the range B3:B14 that is text.

The * character is a wildcard that can be used to represent any number of text characters when searching in text. For example, "A*" would represent any text that starts with A or "*A" would represent any text that ends with A.

Count Cells that Contain Text using the ISTEXT Function

Sometimes data that looks like a number has actually been entered as text. There are a few ways to determine if a cell really contains text data such as the ISTEXT function.

5 Ways to Count Cells that Contain Text in Microsoft Excel (2)
= ISTEXT ( B3 )

The above formula will check the contents of cell B3 and return TRUE if the cell contains text and FALSE if the cells contains a non-text value.

You can then use the ISTEXT function to count the number of text values in your data set.

5 Ways to Count Cells that Contain Text in Microsoft Excel (3)
= SUM ( --ISTEXT ( B3:B14 ) )

The above formula will return the total number of text values in the range B3:B14.

ISTEXT will test each cell in the range B3:B14 and return a TRUE value if it’s text and FALSE otherwise.

The double negative -- converts the array of boolean values to an array of 1‘s or 0‘s where 1 is TRUE or 0 is FALSE. When you take the SUM of this array of 1‘s and 0‘s you will get the count of text values!

Count Cells that Contain Text using Power Query

Excel comes with a tool called power query which allows you to clean and shape your data in almost unlimited ways and you can also use it to count the text values in your dataset.

Power query is best used with data inside Excel tables, so be sure to add your data to an Excel Table first.

5 Ways to Count Cells that Contain Text in Microsoft Excel (4)
  1. Select any cell inside your data.
  2. Go to the Data tab.
  3. Press the From Table/Range command button.

This will open the power query editor where you can build your query to transform your data.

5 Ways to Count Cells that Contain Text in Microsoft Excel (5)

You will need to add a new temporary column to help filter out the non-text values before counting the results.

  1. Go to the Add Column tab in the power query editor.
  2. Select the Custom Column command.
5 Ways to Count Cells that Contain Text in Microsoft Excel (6)

This will open up the Custom Column menu where you will be able to define the formula for the new column.

= Text.Length([Values])
  1. Add the above formula to the Custom column formula input.
  2. Press the OK button.
5 Ways to Count Cells that Contain Text in Microsoft Excel (7)

The new column will return the length as a count of characters for each value. This will only work when the value is text. For any non-text values, this results in an Error.

You can then filter out the Error‘s and null values to get the count of text values.

5 Ways to Count Cells that Contain Text in Microsoft Excel (8)
  1. Right-click on the custom column heading.
  2. Select Remove Errors from the options.
5 Ways to Count Cells that Contain Text in Microsoft Excel (9)

Next, you can filter out any null values if there are any. These will be present if you have any blank cells in the source Excel data.

  1. Left click on the filter toggle in the custom column heading.
  2. Deselect the null value.
  3. Press the OK button.
5 Ways to Count Cells that Contain Text in Microsoft Excel (10)

This will result in only the rows with text values remaining. These are the rows containing a number value in the Custom column.

5 Ways to Count Cells that Contain Text in Microsoft Excel (11)

You can now count the values in the Custom column.

  1. Left click on the Custom column heading to select it.
  2. Go to the Transform tab.
  3. Click on the Statistics command.
  4. Choose the Count Values option in the menu.
5 Ways to Count Cells that Contain Text in Microsoft Excel (12)

This will result in a single value shown in the data preview, and you can then use that value in other queries or load it into Excel.

  1. Go to the Home tab.
  2. Press the Close and Load button.

This single value will then load into a table in your Excel worksheet!

All the above steps should create the following M code behind the scenes.

// Text Countlet Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content], #"Added Custom" = Table.AddColumn(Source, "Custom", each Text.Length([Values])), #"Removed Errors" = Table.RemoveRowsWithErrors(#"Added Custom", {"Custom"}), #"Filtered Rows" = Table.SelectRows(#"Removed Errors", each ([Custom] <> null)), #"Calculated Count" = List.NonNullCount(#"Filtered Rows"[Custom])in #"Calculated Count"

The great thing about a power query is it gets saved as a query that can easily be run again when your data changes.

Go to the Data tab and press the Refresh button and the query will run again and give you the latest text count.

Count Cells that Contain Text using VBA

Visual Basic for Applications (VBA) is a programming language in Excel that can help you automate your work or add functionality to Excel.

5 Ways to Count Cells that Contain Text in Microsoft Excel (13)

This can be used to count text values in a selected range with the click of a button.

Follow these steps to create a VBA script that counts text values.

  1. Press Alt + F11 to open the VBA editor. This is where you can write your VBA code.
  2. Go to the Insert tab in the VBA editor.
  3. Select Module from the menu.
Sub CountText()Dim txtCount As LongtxtCount = Application.WorksheetFunction.CountIf(Selection, "*")MsgBox "Found " & txtCount & " text value(s)"End Sub
  1. Paste the above code into the VBA module.

The code actually uses COUNTIF worksheet function via the Application.WorksheetFunction VBA method.

You can now close the VBA editor and return the Excel workbook to use the macro script.

5 Ways to Count Cells that Contain Text in Microsoft Excel (14)
  1. Select the range of cells in which you would like to count text.
  2. Press Alt + F8 to open the Macro dialog box.
  3. Select the CountText macro.
  4. Press the Run button.
5 Ways to Count Cells that Contain Text in Microsoft Excel (15)

The code will run and return the count of text values in a small pop-up box.

Count Cells that Contain Text using Office Scripts

Excel also offers a feature called Office Scripts, which allows users to automate tasks by creating and running scripts. Office Scripts can be used to perform various tasks, such as updating cells, inserting new data, or deleting data.

Office Scripts is a JavaScript based scripting language that is available in Excel online with Microsoft 365 business plans. It’s meant to be the successor to the aging VBA language.

Using Office Scripts can help users to save time and increase productivity by automating repetitive tasks or creating new functionality within their spreadsheets.

5 Ways to Count Cells that Contain Text in Microsoft Excel (16)
  1. Open your Excel file in Excel Online.
  2. Go to the Automate tab.
  3. Press the New Script command.
5 Ways to Count Cells that Contain Text in Microsoft Excel (17)
function main(workbook: ExcelScript.Workbook) { //Create a range object from selected range let selectedRange = workbook.getSelectedRange(); //Create an array with the data types in the selected range let selectedTypes = selectedRange.getValueTypes(); //Get dimensions of selected range let rowHeight = selectedRange.getRowCount(); let colWidth = selectedRange.getColumnCount(); //Set text counter let textCount = 0; // Loop through each item in the selected range for (let i = 0; i < rowHeight; i++) { for (let j = 0; j < colWidth; j++) { //Test if the value is text if (selectedTypes[i][j].toString() === "String") { //Increment the count textCount++; } } } //Write the count into the sheet just below the selected range selectedRange.getLastCell().getOffsetRange(2, 0).setValue(textCount);};

This will open the script editor where you can write your code.

  1. Paste the above code into the editor.
  2. Press the Save script button.

This code will loop through each cell in the selected range and test if the data type is a string.

The script will keep a running count of the number of cells that contain text and then place the final count into a cell just below the selection.

5 Ways to Count Cells that Contain Text in Microsoft Excel (18)

Now you will be able to count text data in any range!

  1. Select the range of cells to count.
  2. Press the Run button in the script editor.

The count will be calculated and added just below the selected range.

Conclusions

Getting an overview of your data is an essential step to understanding your data. Counting the text values in a column is a very common summary that will help you gain valuable insights.

There are several ways to count text values available in Excel.

The COUNTIFS function can be combined with wildcard characters to count any text in a range. Excel also has the ISTEXT function which can be combined with a SUM to count any text values.

You can also count text values with Power Query, VBA, or Office Scripts depending on the situation.

Do you know any other ways to count text data in Excel? Which method do you prefer? Let me know in the comments below!

5 Ways to Count Cells that Contain Text in Microsoft Excel (2024)

FAQs

How do you count cells that have text in them Excel? ›

On the Formulas tab, click More Functions, point to Statistical, and then click one of the following functions:
  1. COUNTA: To count cells that are not empty.
  2. COUNT: To count cells that contain numbers.
  3. COUNTBLANK: To count cells that are blank.
  4. COUNTIF: To count cells that meets a specified criteria.

How do I find the 5 most common text in Excel? ›

The most frequently occurring text refers to the maximum number of the repetitiveness of a particular text in a string. You can find it using the INDEX, MODE and MATCH functions. The generic function to find the most frequently occurring text is, =INDEX(range, MODE(MATCH(range, range, 0 ))).

How do I count specific answers in Excel? ›

Count how often a single value occurs by using the COUNTIF function. Use the COUNTIF function to count how many times a particular value appears in a range of cells.

What are the 4 count functions? ›

There are five variants of COUNT functions: COUNT, COUNTA, COUNTBLANK, COUNTIF, and COUNTIFS. We need to use the COUNTIF function or COUNTIFS function if we want to count only numbers that meet specific criteria.

How do you count text containing? ›

Count if cell contains text or part of text with the COUNTIF function
  1. =COUNTIF(B5:B10,"*"&D5&"*")
  2. Syntax.
  3. =COUNTIF (range, criteria)
  4. Arguments.
  5. Notes:
  6. =COUNTIF(B5:B10,"*")
  7. Tip. If you want to have a free trial (60-day) of this utility, please click to download it, and then go to apply the operation according above steps.

How do you count words in a cell? ›

The LEN() function takes a cell with text content and gives back the number of characters in that cell. By specifying that we want the LEN() of cell B1 ( LEN(B1) , in cell B2 above), Excel does this calculation for us.

How do I count top 5 values in Excel? ›

Select cell B2, copy and paste formula =LARGE(A$2:A$16,ROWS(B$2:B2)) into the formula bar, then press the Enter key. See screenshot: 2. Select cell B2, drag the fill handle down to cell B6, then the five highest values are showing.

What are the 5 standard operators in Excel choose 5 answer? ›

Excel uses standard operators for formulas, such as a plus sign for addition (+), a minus sign for subtraction (-), an asterisk for multiplication (*), a forward slash for division (/), and a caret (^) for exponents. All formulas in Excel must begin with an equals sign (=).

What are the 7 basic Excel formulas? ›

  • Overview of formulas in Excel. Article.
  • XLOOKUP. Article.
  • VLOOKUP. Article.
  • SUM function. Article.
  • COUNTIF function. Article.
  • IF function. Article.
  • IFS. Article.
  • SUMIF. Article.

What is count methods? ›

Counting methods – usually referred to in GMAT materials as “combinations and permutations” – are generally the lowest-yield math area on the test. By “lowest-yield,” I mean that your score improvement on the test is low relative to the amount of effort you must put in on the topic.

How do I count if a cell contains text sheets? ›

You can also use the COUNTIF function in Google Sheets to count cells with specific text. You can even modify it to count cells that do not contain a specific text. he formula will look like this =COUNTIF(range,”<>criterion”).

What is the fastest way to count words in word? ›

Click on the word count in the status bar to see the number of characters, lines, and paragraphs in your document. Click in your document where you want the word count to appear. Click Insert > Quick Parts > Field. In the Field nameslist, click NumWords, and then click OK.

How do you count cells with and without text? ›

You can use the COUNTIF function with a wildcard to count the number of cells that contain specific text in a range. On the contrary, it is also easy to use the COUNTIF function to count cells that do not contain specific text.

How do you add 5 cells in Excel? ›

Select the cell, or the range of cells, to the right or above where you want to insert additional cells. Tip: Select the same number of cells as you want to insert. For example, to insert five blank cells, select five cells. Hold down CONTROL, click the selected cells, then on the pop-up menu, click Insert.

How do you add 5 numbers from different cells in Excel? ›

Sum a range of cells -- SUM Function

The quickest and easiest way to sum a range of cells is to use the Excel AutoSum button. It automatically enters an Excel SUM function in the selected cell. The SUM function totals one or more numbers in a range of cells.

What are the 5 types of data in Excel? ›

The four types of data are text, number, logical and error. You may perform different functions with each type, so it's important to know which ones to use and when to use them. You may also consider that some data types may change when exporting data into a spreadsheet.

What are the 5 functions of Microsoft Excel? ›

The most frequently used functions in Excel are:
  • AutoSum;
  • IF function;
  • LOOKUP function;
  • VLOOKUP function;
  • HLOOKUP function;
  • MATCH function;
  • CHOOSE function;
  • DATE function;

How do I count top 10 in Excel? ›

Click on the arrow to the right of the Order ID drop down box and select Value Filters > Top 10 from the popup menu. When the Top 10 Filter (Order ID) window appears, select Top, 10, Items, and Sum of Quantity in the respective drop downs. Then click on the OK button.

How do you calculate 5 change in Excel? ›

The formula =(new_value-old_value)/old_value can help you quickly calculate the percentage change between two numbers. Please do as follows. 1. Select a blank cell for locating the calculated percentage change, then enter formula =(A3-A2)/A2 into the Formula Bar, and then press the Enter key.

What are the five counting methods? ›

This video uses manipulatives to review the five counting principles including stable order, correspondence, cardinality, abstraction, and order irrelevance. When students master the verbal counting sequence they display an understanding of the stable order of numbers.

What are the 3 counting techniques? ›

The specific counting techniques we will explore include the multiplication rule, permutations and combinations.

What are the 10 Excel functions? ›

Read on below for a full overview of each function of MS Excel.
  • Table formatting. What it does: transforms your data into an interactive database. ...
  • Pivot tables. What it does: summarizes data and finds unique values. ...
  • Charting. ...
  • COUNTIFS. ...
  • SUMIFS. ...
  • IF Statements. ...
  • CONCATENATE. ...
  • VLOOKUP.
5 Jul 2018

What is function in Excel Class 7? ›

A function is a pre-defined formula that performs calculations by using specific values, called arguments, in a particular order or structure. It can do simple as well as complex calculations.

What are the two types of counting? ›

There are two types of counting: rote counting and rational counting.

What is the use of count () method explain with example? ›

Count() is a Python built-in function that returns the number of times an object appears in a list. The count() method is one of Python's built-in functions. It returns the number of times a given value occurs in a string or a list, as the name implies.

How do you match the first 5 letters in Excel? ›

=LEFT (A2, 5)

and press Enter on the keyboard. The function will return the first 5 characters from the cell.

How do you find the most occurring text in sheets? ›

Select Lookup option from the Formula Type drop down list; Then choose Find most common value from the Choose a fromula list box; In the right Arguments input section, select a list of cells that you want to extract the most common value beside the Range.

How do you pull the first 5 characters of a string? ›

string str = yourStringVariable. Substring(0,5); Remember that String. Substring could throw an exception in case of string's length less than the characters required.

How do I combine 5 cells in Excel? ›

Merge cells
  1. Click the first cell and press Shift while you click the last cell in the range you want to merge. Important: Make sure only one of the cells in the range has data.
  2. Click Home > Merge & Center.

How do I use F5 in Excel? ›

F5 Displays the Go To dialog box. Ctrl+F5 restores the window size of the selected workbook window. F6 Switches between the worksheet, ribbon, task pane, and Zoom controls.

What is the fastest way to find information in Excel? ›

Finding specific records and/or cells is easy when using the Find tool in Excel. It is located within the Find & Select drop down on the Home tab. To use Find you simply type the data you are looking for into the Find what text box. Above, I am looking for records which contain the text Tyler.

How do I count text from multiple sheets in Excel? ›

We can count occurrences for the number of times a particular value (number, text, date, etc.) occurs across several worksheets in an excel workbook. We can do this by applying the COUNTIF, INDIRECT and SUMPRODUCT functions.

What are the five most used spreadsheet functions? ›

5 Functions of Excel/Sheets That Every Professional Should Know
  • VLookup Formula.
  • Concatenate Formula.
  • Text to Columns.
  • Remove Duplicates.
  • Pivot Tables.
23 Jan 2019

Top Articles
Latest Posts
Article information

Author: Duncan Muller

Last Updated:

Views: 6300

Rating: 4.9 / 5 (79 voted)

Reviews: 94% of readers found this page helpful

Author information

Name: Duncan Muller

Birthday: 1997-01-13

Address: Apt. 505 914 Phillip Crossroad, O'Konborough, NV 62411

Phone: +8555305800947

Job: Construction Agent

Hobby: Shopping, Table tennis, Snowboarding, Rafting, Motor sports, Homebrewing, Taxidermy

Introduction: My name is Duncan Muller, I am a enchanting, good, gentle, modern, tasty, nice, elegant person who loves writing and wants to share my knowledge and understanding with you.