Find one word in excel

Excel has some wonderful formulas that can help you slice and dice the text data.

Sometimes, when you have the text data, you may want to extract the first word from the text string in a cell.

There are multiple ways you can do this in Excel (using a combination of formulas, using Find and Replace, and using Flash Fill)

In this tutorial, I will show you some really simple ways to extract the first word from a text string in Excel.

Extract the First Word Using Text Formulas

Suppose you have the following dataset, where you want to get the first word from each cell.

Dataset to Extract the first word from text string

The below formula will do this:

=IFERROR(LEFT(A2,FIND(" ",A2)-1),A2)

Formula to find and extract only the first word

Let me explain how this formula works.

The FIND part of the formula is used to find the position of the space character in the text string. When the formula finds the position of the space character, the LEFT function is used to extract all the characters before that first space character in the text string.

While the LEFT formula alone should be enough, it will give you an error in case there is only one word in the cell and no space characters.

To handle this situation, I have wrapped the LEFT formula in the IFERROR formula, which simply returns the original cell content (as there are no space characters indicating that it’s either empty or has only one word).

One good thing about this method is that the result is dynamic. This means that in case you change the original text string in the cells in column A, the formula in column B will automatically update and give the correct result.

In case you don’t want the formula, you can convert it into values.

Extract the First Word Using Find and Replace

Another quick method to extract the first word is to use Find and Replace to remove everything except the first word.

Suppose you have the dataset as shown below:

Dataset to Extract the first word from text string

Below are the steps to use Find and Replace to only get the first word and remove everything else:

  1. Copy the text from column A to column B. This is to make sure that we have the original data as well.
  2. Select all the cells in Column B where you want to get the first wordCopy the text to Column B
  3. Click the Home tabClick the Home tab
  4. In the Editing group, click on Find and Select option and then click on Replace. This will open the Find & Replace dialog box.Click on Replace
  5. In the Find what field, enter  * (one space character followed by the asterisk sign)Enter Space character followed by asterisk in Find what field
  6. Leave the Replace with field emptyLeave the replace with empty
  7. Click on Replace All button.Click on replace all

The above steps would remove everything except the first word in the cells.

result after find and replace

You can also use the keyboard shortcut Control + H to open the Find and Replace dialog box.

How does this work?

In Find what field, we have used a space character followed by the asterisk sign. The asterisk sign (*) is a wild card character that represents any number of characters.

So when we ask Excel to find cells that contain space character followed by the asterisk sign and replace it with blank, it finds the first space character and removes everything after it – leaving us with the first word only.

And in case you a cell that has no text or only one word with no space characters, the above steps would not make any changes to it.

Extract the First Word Using Flash Fill

Another really simple and fast method to extract the first word using Flash Fill.

Flash Fill was introduced in Excel 2013 and is available in all the versions after that. It helps in text manipulation by identifying the pattern that you’re trying to achieve and fills it for the entire column.

For example, suppose you have the below dataset and you want to only extract the first word.

Dataset to Extract the first word from text string

Below are the steps to do this:

  1. In cell B2, which is the adjacent column of our data, manually enter ‘Marketing’ (which is the expected result)Enter the first word in first cell manually
  2. In cell B3, enter ‘HR’Enter manually in second cell
  3. Select the range B2:B10Select the range
  4. Click on the Home tab
  5. In the Editing group, click on the Fill drop-down
  6. Click on Flash Fill optionClick on Flash Fill

The above steps would fill all the cells with the first word from the adjacent column (column A).

Caution: In most cases, Flash Fill works fine and gives the correct result, but in some cases, it may not give you the right result. Just make sure to double-check that the results are as expected.

Note: When typing the expected result in the second cell in column B, you may see all text in all the cells in a light gray color. That is the result you will get if you hit the enter key right away. In case you don’t see the gray line, use the Flash Fill option in the ribbon.

So these are three simple methods to extract the first word from a text string in Excel.

I hope you found this tutorial useful!

Other Excel tutorials you may like:

  • Extract Numbers from a String in Excel (Using Formulas or VBA)
  • How to Extract a Substring in Excel (Using TEXT Formulas)
  • Separate First and Last Name in Excel (Split Names Using Formulas)
  • How to Remove Comma in Excel (from Text and Numbers)
  • How To Remove Text Before Or After a Specific Character In Excel
  • How to Combine First and Last Name in Excel
  • Remove Characters From Left in Excel
  • Separate Text and Numbers in Excel

Summary

If you need to extract the first word from some text you can use a formula that uses the FIND and LEFT functions. From the example, the formula looks like this:

=LEFT(B4,FIND(" ",B4)-1)

Generic formula

Explanation 

FIND returns the position (as a number) of the first occurrence of a space character in the text. This position, minus one, is fed into the LEFT function as num_chars.

The LEFT function then extracts characters starting at the the left side of the text, up to (position — 1).

Handling one word

If a cell contains only one word, this formula returns an error. One way to fix this problem is to wrap the original formula in the IFERROR function like so:

=IFERROR(LEFT(B4,FIND(" ",B4)-1),B4)

Translated: if an error occurs, return the original text.

Another simple way to handle the error is to append a space to the cell value before running FIND:

=LEFT(B4,FIND(" ",B4&" ")-1)

This ensures that FIND will always find at least one space, and will therefore not throw an error. When a cell contains more than one word, there is no impact because the formula works only with the first space.

Dave Bruns Profile Picture

AuthorMicrosoft Most Valuable Professional Award

Dave Bruns

Hi — I’m Dave Bruns, and I run Exceljet with my wife, Lisa. Our goal is to help you work faster in Excel. We create short videos, and clear examples of formulas, functions, pivot tables, conditional formatting, and charts.

There are hundreds and hundreds of Excel sites out there. I’ve been to many and most are an exercise in frustration. Found yours today and wanted to let you know that it might be the simplest and easiest site that will get me where I want to go.

Get Training

Quick, clean, and to the point training

Learn Excel with high quality video training. Our videos are quick, clean, and to the point, so you can learn Excel in less time, and easily review key topics when needed. Each video comes with its own practice worksheet.

View Paid Training & Bundles

Help us improve Exceljet

Connect with an expert. Learn from live instructors.

Use the Find and Replace features in Excel to search for something in your workbook, such as a particular number or text string. You can either locate the search item for reference, or you can replace it with something else. You can include wildcard characters such as question marks, tildes, and asterisks, or numbers in your search terms. You can search by rows and columns, search within comments or values, and search within worksheets or entire workbooks.

Your browser does not support video. Install Microsoft Silverlight, Adobe Flash Player, or Internet Explorer 9.

Find

To find something, press Ctrl+F, or go to Home > Editing > Find & Select > Find.

Note: In the following example, we’ve clicked the Options >> button to show the entire Find dialog. By default, it will display with Options hidden.

Press Ctrl+F to launch the Find dialog

  1. In the Find what: box, type the text or numbers you want to find, or click the arrow in the Find what: box, and then select a recent search item from the list.

    Tips: You can use wildcard characters — question mark (?), asterisk (*), tilde (~) — in your search criteria.

    • Use the question mark (?) to find any single character — for example, s?t finds «sat» and «set».

    • Use the asterisk (*) to find any number of characters — for example, s*d finds «sad» and «started».

    • Use the tilde (~) followed by ?, *, or ~ to find question marks, asterisks, or other tilde characters  — for example, fy91~? finds «fy91?».

  2. Click Find All or Find Next to run your search.

    Tip: When you click Find All, every occurrence of the criteria that you are searching for will be listed, and clicking a specific occurrence in the list will select its cell. You can sort the results of a Find All search by clicking a column heading.

  3. Click Options>> to further define your search if needed:

    • Within: To search for data in a worksheet or in an entire workbook, select Sheet or Workbook.

    • Search: You can choose to search either By Rows (default), or By Columns.

    • Look in: To search for data with specific details, in the box, click Formulas, Values, Notes, or Comments.

      Note:   Formulas, Values, Notes and Comments are only available on the Find tab; only Formulas are available on the Replace tab.

    • Match case — Check this if you want to search for case-sensitive data.

    • Match entire cell contents — Check this if you want to search for cells that contain just the characters that you typed in the Find what: box.

  4. If you want to search for text or numbers with specific formatting, click Format, and then make your selections in the Find Format dialog box.

    Tip: If you want to find cells that just match a specific format, you can delete any criteria in the Find what box, and then select a specific cell format as an example. Click the arrow next to Format, click Choose Format From Cell, and then click the cell that has the formatting that you want to search for.

Replace

To replace text or numbers, press Ctrl+H, or go to Home > Editing > Find & Select > Replace.

Note: In the following example, we’ve clicked the Options >> button to show the entire Find dialog. By default, it will display with Options hidden.

Press Ctrl+H to launch the Replace dialog.

  1. In the Find what: box, type the text or numbers you want to find, or click the arrow in the Find what: box, and then select a recent search item from the list.

    Tips: You can use wildcard characters — question mark (?), asterisk (*), tilde (~) — in your search criteria.

    • Use the question mark (?) to find any single character — for example, s?t finds «sat» and «set».

    • Use the asterisk (*) to find any number of characters — for example, s*d finds «sad» and «started».

    • Use the tilde (~) followed by ?, *, or ~ to find question marks, asterisks, or other tilde characters  — for example, fy91~? finds «fy91?».

  2. In the Replace with: box, enter the text or numbers you want to use to replace the search text.

  3. Click Replace All or Replace.

    Tip: When you click Replace All, every occurrence of the criteria that you are searching for will be replaced, while Replace will update one occurrence at a time.

  4. Click Options>> to further define your search if needed:

    • Within: To search for data in a worksheet or in an entire workbook, select Sheet or Workbook.

    • Search: You can choose to search either By Rows (default), or By Columns.

    • Look in: To search for data with specific details, in the box, click Formulas, Values, Notes, or Comments.

      Note:   Formulas, Values, Notes and Comments are only available on the Find tab; only Formulas are available on the Replace tab.

    • Match case — Check this if you want to search for case-sensitive data.

    • Match entire cell contents — Check this if you want to search for cells that contain just the characters that you typed in the Find what: box.

  5. If you want to search for text or numbers with specific formatting, click Format, and then make your selections in the Find Format dialog box.

    Tip: If you want to find cells that just match a specific format, you can delete any criteria in the Find what box, and then select a specific cell format as an example. Click the arrow next to Format, click Choose Format From Cell, and then click the cell that has the formatting that you want to search for.

There are two distinct methods for finding or replacing text or numbers on the Mac. The first is to use the Find & Replace dialog. The second is to use the Search bar in the ribbon.

Find & Replace dialog

Search bar and options

Find window

  1. Press Ctrl+F or go to Home > Find & Select > Find.

  2. In Find what: type the text or numbers you want to find.

  3. Select Find Next to run your search.

  4. You can further define your search:

    • Within: To search for data in a worksheet or in an entire workbook, select Sheet or Workbook.

    • Search: You can choose to search either By Rows (default), or By Columns.

    • Look in: To search for data with specific details, in the box, click Formulas, Values, Notes, or Comments.

    • Match case — Check this if you want to search for case-sensitive data.

    • Match entire cell contents — Check this if you want to search for cells that contain just the characters that you typed in the Find what: box.

Tips: You can use wildcard characters — question mark (?), asterisk (*), tilde (~) — in your search criteria.

  • Use the question mark (?) to find any single character — for example, s?t finds «sat» and «set».

  • Use the asterisk (*) to find any number of characters — for example, s*d finds «sad» and «started».

  • Use the tilde (~) followed by ?, *, or ~ to find question marks, asterisks, or other tilde characters  — for example, fy91~? finds «fy91?».

Find Options

  1. Press Ctrl+F or go to Home > Find & Select > Find.

  2. In Find what: type the text or numbers you want to find.

  3. Select Find All to run your search for all occurrences.

    Find all drop display

    Note:  The dialog box expands to show a list of all the cells that contain the search term, and the total number of cells in which it appears.

  4. Select any item in the list to highlight the corresponding cell in your worksheet.
     

    Note: You can edit the contents of the highlighted cell.

  1. Press Ctrl+H or go to Home > Find & Select > Replace.

  2. In Find what, type the text or numbers you want to find.

  3. You can further define your search:

    • Within: To search for data in a worksheet or in an entire workbook, select Sheet or Workbook.

    • Search: You can choose to search either By Rows (default), or By Columns.

    • Match case — Check this if you want to search for case-sensitive data.

    • Match entire cell contents — Check this if you want to search for cells that contain just the characters that you typed in the Find what: box.
       

      Tips: You can use wildcard characters — question mark (?), asterisk (*), tilde (~) — in your search criteria.

      • Use the question mark (?) to find any single character — for example, s?t finds «sat» and «set».

      • Use the asterisk (*) to find any number of characters — for example, s*d finds «sad» and «started».

      • Use the tilde (~) followed by ?, *, or ~ to find question marks, asterisks, or other tilde characters — for example, fy91~? finds «fy91?».

  4. In the Replace with box, enter the text or numbers you want to use to replace the search text.

  5. Select Replace or Replace All.

    Tips: 

    • When you select Replace All, every occurrence of the criteria that you are searching for is replaced.

    • When you select Replace, you can replace one instance at a time by selecting Next to highlight the next instance.

  1. Select any cell to search the entire sheet or select a specific range of cells to search.

  2. Press Command + F or select the magnifying glass to expand the Search bar and type the text or number you want to find in the search field.

    Tips: You can use wildcard characters — question mark (?), asterisk (*), tilde (~) — in your search criteria.

    • Use the question mark (?) to find any single character — for example, s?t finds «sat» and «set».

    • Use the asterisk (*) to find any number of characters — for example, s*d finds «sad» and «started».

    • Use the tilde (~) followed by ?, *, or ~ to find question marks, asterisks, or other tilde characters — for example, fy91~? finds «fy91?».

  3. Press return.

    Notes: 

    • To find the next instance of the item you are searching for, press return again or use the Find dialog box and select Find Next.

    • To specify additional search options, select the magnifying glass and select Search in Sheet or Search in Workbook. You can also select the Advanced option, which launches the Find dialog.

    Tip: You can cancel a search in progress by pressing ESC.

Find

To find something, press Ctrl+F, or go to Home > Editing > Find & Select > Find.

Note: In the following example, we’ve clicked > Search Options to show the entire Find dialog. By default, it will display with Search Options hidden.

Find text or numbers in a workbook or worksheet by pressing Ctrl+F

  1. In the Find what: box, type the text or numbers you want to find.

    Tips: You can use wildcard characters — question mark (?), asterisk (*), tilde (~) — in your search criteria.

    • Use the question mark (?) to find any single character — for example, s?t finds «sat» and «set».

    • Use the asterisk (*) to find any number of characters — for example, s*d finds «sad» and «started».

    • Use the tilde (~) followed by ?, *, or ~ to find question marks, asterisks, or other tilde characters  — for example, fy91~? finds «fy91?».

  2. Click Find Next or Find All to run your search.

    Tip: When you click Find All, every occurrence of the criteria that you are searching for will be listed, and clicking a specific occurrence in the list will select its cell. You can sort the results of a Find All search by clicking a column heading.

  3. Click > Search Options to further define your search if needed:

    • Within: To search for data within a certain selection, choose Selection. To search for data in a worksheet or in an entire workbook, select Sheet or Workbook.

    • Direction: You can choose to search either Down (default), or Up.

    • Match case — Check this if you want to search for case-sensitive data.

    • Match entire cell contents — Check this if you want to search for cells that contain just the characters that you typed in the Find what box.

Replace

To replace text or numbers, press Ctrl+H, or go to Home > Editing > Find & Select > Replace.

Note: In the following example, we’ve clicked > Search Options to show the entire Find dialog. By default, it will display with Search Options hidden.

Replace text or numbers in a workbook or worksheet by pressing Ctrl+H

  1. In the Find what: box, type the text or numbers you want to find.

    Tips: You can use wildcard characters — question mark (?), asterisk (*), tilde (~) — in your search criteria.

    • Use the question mark (?) to find any single character — for example, s?t finds «sat» and «set».

    • Use the asterisk (*) to find any number of characters — for example, s*d finds «sad» and «started».

    • Use the tilde (~) followed by ?, *, or ~ to find question marks, asterisks, or other tilde characters  — for example, fy91~? finds «fy91?».

  2. In the Replace with: box, enter the text or numbers you want to use to replace the search text.

  3. Click Replace or Replace All.

    Tip: When you click Replace All, every occurrence of the criteria that you are searching for will be replaced, while Replace will update one occurrence at a time.

  4. Click > Search Options to further define your search if needed:

    • Within: To search for data within a certain selection, choose Selection. To search for data in a worksheet or in an entire workbook, select Sheet or Workbook.

    • Direction: You can choose to search either Down (default), or Up.

    • Match case — Check this if you want to search for case-sensitive data.

    • Match entire cell contents — Check this if you want to search for cells that contain just the characters that you typed in the Find what box.

Need more help?

You can always ask an expert in the Excel Tech Community or get support in the Answers community.

Recommended articles

Merge and unmerge cells

REPLACE, REPLACEB functions

Apply data validation to cells

Функция НАЙТИ (FIND) в Excel используется для поиска текстового значения внутри строчки с текстом и указать порядковый номер буквы с которого начинается искомое слово в найденной строке.

Содержание

  1. Что возвращает функция
  2. Синтаксис
  3. Аргументы функции
  4. Дополнительная информация
  5. Примеры использования функции НАЙТИ в Excel
  6. Пример 1. Ищем слово в текстовой строке (с начала строки)
  7. Пример 2. Ищем слово в текстовой строке (с заданным порядковым номером старта поиска)
  8. Пример 3. Поиск текстового значения внутри текстовой строки с дублированным искомым значением

Что возвращает функция

Возвращает числовое значение, обозначающее стартовую позицию текстовой строчки внутри другой текстовой строчки.

Синтаксис

=FIND(find_text, within_text, [start_num]) — английская версия

=НАЙТИ(искомый_текст;просматриваемый_текст;[нач_позиция]) — русская версия

Аргументы функции

  • find_text (искомый_текст) — текст или строка которую вы хотите найти в рамках другой строки;
  • within_text (просматриваемый_текст) — текст, внутри которого вы хотите найти аргумент find_text (искомый_текст);
  • [start_num] ([нач_позиция]) — число, отображающее позицию, с которой вы хотите начать поиск. Если аргумент не указать, то поиск начнется сначала.

Дополнительная информация

  • Если стартовое число не указано, то функция начинает поиск искомого текста с начала строки;
  • Функция НАЙТИ чувствительна к регистру. Если вы хотите сделать поиск без учета регистра, используйте функцию SEARCH в Excel;
  • Функция не учитывает подстановочные знаки при поиске. Если вы хотите использовать подстановочные знаки для поиска, используйте функцию SEARCH в Excel;
  • Функция каждый раз возвращает ошибку, когда не находит искомый текст в заданной строке.

Примеры использования функции НАЙТИ в Excel

Пример 1. Ищем слово в текстовой строке (с начала строки)

Функция НАЙТИ в Excel

На примере выше мы ищем слово «Доброе» в словосочетании «Доброе Утро». По результатам поиска, функция выдает число «1», которое обозначает, что слово «Доброе» начинается с первой по очереди буквы в, заданной в качестве области поиска, текстовой строке.

Telegram Logo Больше лайфхаков в нашем Telegram Подписаться

Обратите внимание, что так как функция НАЙТИ в Excel чувствительна к регистру, вы не сможете найти слово «доброе» в словосочетании «Доброе утро», так как оно написано с маленькой буквы. Для того, чтобы осуществить поиска без учета регистра следует пользоваться функцией SEARCH.

Пример 2. Ищем слово в текстовой строке (с заданным порядковым номером старта поиска)

Функция НАЙТИ в Excel

Третий аргумент функции НАЙТИ указывает позицию, с которой функция начинает поиск искомого значения. На примере выше функция возвращает число «1» когда мы начинаем поиск слова «Доброе» в словосочетании «Доброе утро» с начала текстовой строки. Но если мы зададим аргумент функции start_num (нач_позиция) со значением «2», то функция выдаст ошибку, так как начиная поиск со второй буквы текстовой строки, она не может ничего найти.

Если вы не укажете номер позиции, с которой функции следует начинать поиск искомого аргумента, то Excel по умолчанию начнет поиск с самого начала текстовой строки.

Пример 3. Поиск текстового значения внутри текстовой строки с дублированным искомым значением

Функция НАЙТИ в Excel

На примере выше мы ищем слово «Доброе» в словосочетании «Доброе Доброе утро». Когда мы начинаем поиск слова «Доброе» с начала текстовой строки, то функция выдает число «1», так как первое слово «Доброе» начинается с первой буквы в словосочетании «Доброе Доброе утро».

Но, если мы укажем в качестве аргумента start_num (нач_позиция) число «2» и попросим функцию начать поиск со второй буквы в заданной текстовой строке, то функция выдаст число «6», так как Excel находит искомое слово «Доброе» начиная со второй буквы словосочетания «Доброе Доброе утро» только на 6 позиции.

Содержание

  1. In Excel, how do I find one word in a set of text in a cell?
  2. In Excel, how do I find one word in a set of text in a cell?
  3. RE: In Excel, how do I find one word in a set of text in a cell?
  4. RE: In Excel, how do I find one word in a set of text in a cell?
  5. RE: In Excel, how do I find one word in a set of text in a cell?
  6. RE: In Excel, how do I find one word in a set of text in a cell?
  7. Re: In Excel, how do I find one word in a set of text in a cell?
  8. Re: In Excel, how do I find one word in a set of text in a cell?
  9. FIND, FINDB functions
  10. Description
  11. Syntax
  12. Remarks
  13. Examples
  14. How to Extract the First Word from a Text String in Excel (3 Easy Ways)
  15. Extract the First Word Using Text Formulas
  16. Extract the First Word Using Find and Replace
  17. Extract the First Word Using Flash Fill

In Excel, how do I find one word in a set of text in a cell?

LinkBack
Thread Tools
Rate This Thread
Display

In Excel, how do I find one word in a set of text in a cell?

I am trying to find all instances of a word in a set of words in a cell.

e.g. The cow jumped over the moon

I want to find all instances of cow.

RE: In Excel, how do I find one word in a set of text in a cell?

Do you want to know if it’s present or how many times it’s present in the
cell.

If «The cow jumped over the moon» is in A1 and you want to know if cow is
present in A1, try this:

«man818» wrote:

> I am trying to find all instances of a word in a set of words in a cell.
>
> e.g. The cow jumped over the moon
>
> I want to find all instances of cow.
>
>

RE: In Excel, how do I find one word in a set of text in a cell?

If I got right it, you wanted to count the number of occurences of a
substring within a string?

In that case, a custom function can be made using VBA which goes like this.

Public Function CountIn(strText As String, strFind As String, _
Optional lngCompare As VbCompareMethod = vbBinaryCompare) As Long

Dim lngCount As Long
Dim lngPos As Long

If Len(strFind) > 0 Then
lngPos = 1
Do
lngPos = InStr(lngPos, strText, strFind, lngCompare)
If lngPos > 0 Then
lngCount = lngCount + 1
lngPos = lngPos + Len(strFind)
End If
Loop While lngPos > 0
Else
lngCount = 0
End If
CountIn = lngCount
End Function

You’ll have to place this in a code module in the VBA window (you may access
this by pressing Alt+F11).

Once inputted the syntax of the custom function would now be entered as.

where string = «the cow jumped over the moon» and substring = «cow»

You may try adding «cow» substrings within the string to check.

Hope this helps!


Thanks and kind regards

«man818» wrote:

> I am trying to find all instances of a word in a set of words in a cell.
>
> e.g. The cow jumped over the moon
>
> I want to find all instances of cow.
>
>

RE: In Excel, how do I find one word in a set of text in a cell?

-String can use the cell address of the original data
-Substring should be enclosed in double quotes

Thanks and kind regards

«RaymundCG» wrote:

> Hi!
>
> If I got right it, you wanted to count the number of occurences of a
> substring within a string?
>
> In that case, a custom function can be made using VBA which goes like this.
>
> Public Function CountIn(strText As String, strFind As String, _
> Optional lngCompare As VbCompareMethod = vbBinaryCompare) As Long
>
> Dim lngCount As Long
> Dim lngPos As Long
>
> If Len(strFind) > 0 Then
> lngPos = 1
> Do
> lngPos = InStr(lngPos, strText, strFind, lngCompare)
> If lngPos > 0 Then
> lngCount = lngCount + 1
> lngPos = lngPos + Len(strFind)
> End If
> Loop While lngPos > 0
> Else
> lngCount = 0
> End If
> CountIn = lngCount
> End Function
>
> You’ll have to place this in a code module in the VBA window (you may access
> this by pressing Alt+F11).
>
> Once inputted the syntax of the custom function would now be entered as.
>
> =CountIn(string,substring)
>
> where string = «the cow jumped over the moon» and substring = «cow»
>
> You may try adding «cow» substrings within the string to check.
>
> Hope this helps!
>
> —
> Thanks and kind regards
>
>
> «man818» wrote:
>
> > I am trying to find all instances of a word in a set of words in a cell.
> >
> > e.g. The cow jumped over the moon
> >
> > I want to find all instances of cow.
> >
> >

RE: In Excel, how do I find one word in a set of text in a cell?

This custom function is case sensitive; use the ff syntax as applicable:

=CountIn(string,substring,0) for case sensitive substring entries or
=CountIn(string,substring,1) if not case sensitive


Thanks and kind regards

«RaymundCG» wrote:

> Hi!
>
> If I got right it, you wanted to count the number of occurences of a
> substring within a string?
>
> In that case, a custom function can be made using VBA which goes like this.
>
> Public Function CountIn(strText As String, strFind As String, _
> Optional lngCompare As VbCompareMethod = vbBinaryCompare) As Long
>
> Dim lngCount As Long
> Dim lngPos As Long
>
> If Len(strFind) > 0 Then
> lngPos = 1
> Do
> lngPos = InStr(lngPos, strText, strFind, lngCompare)
> If lngPos > 0 Then
> lngCount = lngCount + 1
> lngPos = lngPos + Len(strFind)
> End If
> Loop While lngPos > 0
> Else
> lngCount = 0
> End If
> CountIn = lngCount
> End Function
>
> You’ll have to place this in a code module in the VBA window (you may access
> this by pressing Alt+F11).
>
> Once inputted the syntax of the custom function would now be entered as.
>
> =CountIn(string,substring)
>
> where string = «the cow jumped over the moon» and substring = «cow»
>
> You may try adding «cow» substrings within the string to check.
>
> Hope this helps!
>
> —
> Thanks and kind regards
>
>
> «man818» wrote:
>
> > I am trying to find all instances of a word in a set of words in a cell.
> >
> > e.g. The cow jumped over the moon
> >
> > I want to find all instances of cow.
> >
> >

Re: In Excel, how do I find one word in a set of text in a cell?

I found your response useful. Thanks for posting.
I do have a question, What if in this same example, I want to look for: «cow jumped over»
So I figured how to do two words like cow and jumped within the same formula you provided. But I just can not add a third word, any help you can provide?
Thanks.

Re: In Excel, how do I find one word in a set of text in a cell?

I found your response useful. Thanks for posting.
I do have a question, What if in this same example, I want to look for: «cow jumped over»
So I figured how to do two words like cow and jumped within the same formula you provided. But I just can not add a third word, any help you can provide?
Thanks.

Источник

FIND, FINDB functions

This article describes the formula syntax and usage of the FIND and FINDB functions in Microsoft Excel.

Description

FIND and FINDB locate one text string within a second text string, and return the number of the starting position of the first text string from the first character of the second text string.

These functions may not be available in all languages.

FIND is intended for use with languages that use the single-byte character set (SBCS), whereas FINDB is intended for use with languages that use the double-byte character set (DBCS). The default language setting on your computer affects the return value in the following way:

FIND always counts each character, whether single-byte or double-byte, as 1, no matter what the default language setting is.

FINDB counts each double-byte character as 2 when you have enabled the editing of a language that supports DBCS and then set it as the default language. Otherwise, FINDB counts each character as 1.

The languages that support DBCS include Japanese, Chinese (Simplified), Chinese (Traditional), and Korean.

Syntax

FIND(find_text, within_text, [start_num])

FINDB(find_text, within_text, [start_num])

The FIND and FINDB function syntax has the following arguments:

Find_text Required. The text you want to find.

Within_text Required. The text containing the text you want to find.

Start_num Optional. Specifies the character at which to start the search. The first character in within_text is character number 1. If you omit start_num, it is assumed to be 1.

FIND and FINDB are case sensitive and don’t allow wildcard characters. If you don’t want to do a case sensitive search or use wildcard characters, you can use SEARCH and SEARCHB.

If find_text is «» (empty text), FIND matches the first character in the search string (that is, the character numbered start_num or 1).

Find_text cannot contain any wildcard characters.

If find_text does not appear in within_text, FIND and FINDB return the #VALUE! error value.

If start_num is not greater than zero, FIND and FINDB return the #VALUE! error value.

If start_num is greater than the length of within_text, FIND and FINDB return the #VALUE! error value.

Use start_num to skip a specified number of characters. Using FIND as an example, suppose you are working with the text string «AYF0093.YoungMensApparel». To find the number of the first «Y» in the descriptive part of the text string, set start_num equal to 8 so that the serial-number portion of the text is not searched. FIND begins with character 8, finds find_text at the next character, and returns the number 9. FIND always returns the number of characters from the start of within_text, counting the characters you skip if start_num is greater than 1.

Examples

Copy the example data in the following table, and paste it in cell A1 of a new Excel worksheet. For formulas to show results, select them, press F2, and then press Enter. If you need to, you can adjust the column widths to see all the data.

Источник

Excel has some wonderful formulas that can help you slice and dice the text data.

Sometimes, when you have the text data, you may want to extract the first word from the text string in a cell.

There are multiple ways you can do this in Excel (using a combination of formulas, using Find and Replace, and using Flash Fill)

In this tutorial, I will show you some really simple ways to extract the first word from a text string in Excel.

This Tutorial Covers:

Suppose you have the following dataset, where you want to get the first word from each cell.

The below formula will do this:

Let me explain how this formula works.

The FIND part of the formula is used to find the position of the space character in the text string. When the formula finds the position of the space character, the LEFT function is used to extract all the characters before that first space character in the text string.

While the LEFT formula alone should be enough, it will give you an error in case there is only one word in the cell and no space characters.

To handle this situation, I have wrapped the LEFT formula in the IFERROR formula, which simply returns the original cell content (as there are no space characters indicating that it’s either empty or has only one word).

One good thing about this method is that the result is dynamic. This means that in case you change the original text string in the cells in column A, the formula in column B will automatically update and give the correct result.

In case you don’t want the formula, you can convert it into values.

Extract the First Word Using Find and Replace

Another quick method to extract the first word is to use Find and Replace to remove everything except the first word.

Suppose you have the dataset as shown below:

Below are the steps to use Find and Replace to only get the first word and remove everything else:

  1. Copy the text from column A to column B. This is to make sure that we have the original data as well.
  2. Select all the cells in Column B where you want to get the first word
  3. Click the Home tab
  4. In the Editing group, click on Find and Select option and then click on Replace. This will open the Find & Replace dialog box.
  5. In the Find what field, enter * (one space character followed by the asterisk sign)
  6. Leave the Replace with field empty
  7. Click on Replace All button.

The above steps would remove everything except the first word in the cells.

How does this work?

In Find what field, we have used a space character followed by the asterisk sign. The asterisk sign (*) is a wild card character that represents any number of characters.

So when we ask Excel to find cells that contain space character followed by the asterisk sign and replace it with blank, it finds the first space character and removes everything after it – leaving us with the first word only.

And in case you a cell that has no text or only one word with no space characters, the above steps would not make any changes to it.

Another really simple and fast method to extract the first word using Flash Fill.

Flash Fill was introduced in Excel 2013 and is available in all the versions after that. It helps in text manipulation by identifying the pattern that you’re trying to achieve and fills it for the entire column.

For example, suppose you have the below dataset and you want to only extract the first word.

Below are the steps to do this:

  1. In cell B2, which is the adjacent column of our data, manually enter ‘Marketing’ (which is the expected result)
  2. In cell B3, enter ‘HR’
  3. Select the range B2:B10
  4. Click on the Home tab
  5. In the Editing group, click on the Fill drop-down
  6. Click on Flash Fill option

The above steps would fill all the cells with the first word from the adjacent column (column A).

Note: When typing the expected result in the second cell in column B, you may see all text in all the cells in a light gray color. That is the result you will get if you hit the enter key right away. In case you don’t see the gray line, use the Flash Fill option in the ribbon.

So these are three simple methods to extract the first word from a text string in Excel.

I hope you found this tutorial useful!

Other Excel tutorials you may like:

Источник

Like this post? Please share to your friends:
  • Find one word for many words
  • Find one word for definition
  • Find one word for a sentence
  • Find one odd word out перевод
  • Find odd word which is not used with do