Excel replace if found

Содержание

  1. Find or replace text and numbers on a worksheet
  2. Replace
  3. Excel Find and Replace
  4. Basic Excel Find
  5. Excel Find All
  6. Basic Excel Find and Replace
  7. Excel Replace All
  8. Using Wildcards Within the Excel Find Command
  9. Find Within a Specified Range of Cells
  10. Additional Find Options
  11. Within: Option
  12. Search: Option
  13. Look in: Option
  14. Match case Option
  15. Match Entire Cell Contents Option
  16. Find and Replace a Formatting Style
  17. How to Remove a Formatting Style in Excel Find and Replace
  18. Simple excel find and replace for formulas
  19. 5 Answers 5

Find or replace text and numbers on a worksheet

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.

Tip: You can also use formulas to replace text. Check out the SUBSTITUTE function or REPLACE, REPLACEB functions to learn more.

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.

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».

) followed by ?, *, or

to find question marks, asterisks, or other tilde characters — for example, fy91

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.

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.

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.

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».

) followed by ?, *, or

to find question marks, asterisks, or other tilde characters — for example, fy91

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

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.

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.

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.

Источник

Excel Find and Replace

Basic Excel Find

In order to find an occurrence of a specific value in an Excel spreadsheet:

Click on the Find & Select icon (which is located within the ‘Editing’ group on the Home tab of the Excel ribbon), then select the option Find. (see right above ).

Note that the keyboard shortcut for this is Ctrl + F .

You will be presented with the Excel Find and Replace dialog box, with the Find tab selected, as shown below:

Within the dialog box:

  • Type the text or numeric value that you want to find into the Find what: field;
  • Click on the Find Next button.

This will take you to the next occurrence of the required value within the current worksheet.

Excel Find All

If you want to find all occurrences of a specific value, you can click on the Find All button within the Find and Replace dialog box. This brings up a list of all occurrences of your search value, as shown on the right above .

Clicking on each of the values in the list will take you to the corresponding cell in your spreadsheet.

Basic Excel Find and Replace

In order to replace one or more occurrences of a specific value in an Excel spreadsheet:

Click on the Find & Select button (which is located within the Editing group of the Home tab), then select the option Replace. (see right above ).

Note that the keyboard shortcut for this is Ctrl + H .

You will be presented with the Excel Find and Replace dialog box, with the Replace tab selected, as shown below:

Within the dialog box:

    Type the text that you want to find into the Find what: field;

Type the text that you want to replace with into the Replace with: field;

Note that you can leave this field blank if you simply wish to remove all instances of the ‘find text’, (i.e. replace with nothing).

  • Click on the Find Next button. This will take you to the first occurrence of the ‘find text’.
  • In order to replace the current instance of the ‘find text’ with the specified ‘replace’ text, click on the Replace button. The text will be replaced and you will be taken to the next occurrence of the ‘find text’.
  • Excel Replace All

    If you are confident that you want to replace all occurrences of the ‘find text’ with the ‘replace text’ (without checking each instance individually), simply click on the Replace All button within the dialog box.

    Using Wildcards Within the Excel Find Command

    The Excel Find command can handle the following wildcards:

    ? — matches any single character
    * — matches any sequence of characters

    (Note that, if you actually want to find the ? or * character, you need to type the

    symbol before this character in your search).

    • The search term condition «a*e» will find all cells containing the letter «a» followed by an «e», with any combination of characters falling between the «a» and the «e».
    • The search term condition «a?e» will find all cells containing the letter «a» followed by any single character and then the letter «e».

    Find Within a Specified Range of Cells

    If you want the Excel find command to only search a specific range of cells, select the range that you want to search before performing the find (or the find and replace).

    For example, in the above spreadsheet on the right , the range A2 — A6 is selected. Therefore, a search for the text string «Smith» will find this text string in cells A2 and A5, but will not find the text string «Smith» that occurs in cell A8.

    Additional Find Options

    The Excel Find command can be refined using a number of options, which can be displayed by clicking on the Options >> button in the Find and Replace dialog box.

    Clicking on the Options >> button causes the dialog box to expand as shown below:

    Note that most of these options are also available in the Replace tab of the dialog box.

    Each of the options is discussed below:

    Within: Option

    The Excel Find Within: Option allows the user to decide whether the Find command should search in the current active worksheet only, or throughout the entire current workbook.

    Search: Option

    The Excel Find Search: Option allows the user to decide the order that Excel searches through a worksheet.

    • If this option is set to ‘By Rows’, Excel searches across each row before continuing the search at the start of the next row, etc.
    • If this option is set to ‘By Columns’, Excel searches down each column before continuing the search at the top of the next column, etc.

    Look in: Option

    The Look in: Option allows the user to decide what is to be searched. Possible options are:

    • Formulas — If a cell contains a formula, the text that makes up the formula will be searched, rather than the result of the formula.
    • Values(not available on the Replace tab) — If a cell contains a formula, the result of the formula will be searched (not the actual formula itself).
    • Comments(not available on the Replace tab) — Only cell comments are searched; Any other cell contents are ignored.

    Match case Option

    The Match case option allows a user to request that the Find command should be case-sensitive.

    • If the Match case option is not checked (the default option), the Excel Find command is not case-sensitive.
    • If the Match case option is checked, the Excel Find command is case-sensitive.

    Match Entire Cell Contents Option

    The Match Entire Cell Contents option allows a user to request whether the Find command should match any part of a cell’s contents or should only match if the ‘find text’ is equal to an entire cell’s contents.

    • If the Match Entire Cell Contents option is not checked (the default option), the Excel Find command finds any instances of the ‘find text’ that occur in any part of a cell.
    • If the Match Entire Cell Contents option is checked, the Excel Find command only finds cells for which the entire contents of the cell match the ‘find text’.

    Find and Replace a Formatting Style

    Also within the Excel Find and Replace dialog box, you will see the Format. button. This allows you to specify a format that you want to find and (optionally) a Replace format.

    Note that if you specify a formatting style and a ‘find text’ value, the Find command will only find cells that match both the formatting style and the specified ‘find text’.

    How to Remove a Formatting Style in Excel Find and Replace

    If you want to remove a previously specified formatting style from the Find and Replace dialog box, click on the arrow at the side of the Format. button and select the option Clear Find Format (see below).

    Further details on the Excel Find and Replace command are provided on the Microsoft Office Support website.

    Источник

    Simple excel find and replace for formulas

    I have numerous cells all over the place on a worksheet that look like =((E9-E8)/E8) . I want to use the first two values to go into this new formula, (EXP((LN(E9/E8)/14.32))-1) .

    How can I change them all to the new formula in one fell swoop?

    5 Answers 5

    If the formulas are identical you can use Find and Replace with Match entire cell contents checked and Look in: Formulas . Select the range, go into Find and Replace, make your entries and `Replace All.

    Or do you mean that there are several formulas with this same form, but different cell references? If so, then one way to go is a regular expression match and replace. Regular expressions are not built into Excel (or VBA), but can be accessed via Microsoft’s VBScript Regular Expressions library.

    The following function provides the necessary match and replace capability. It can be used in a subroutine that would identify cells with formulas in the specified range and use the formulas as inputs to the function. For formulas strings that match the pattern you are looking for, the function will produce the replacement formula, which could then be written back to the worksheet.

    In order for the function to work, you would need to add a reference to the Microsoft VBScript Regular Expressions 5.5 library. From the Developer tab of the main ribbon, select VBA and then References from the main toolbar. Scroll down to find the reference to the library and check the box next to it.

    Источник

    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

    Skip to content

    How to Use Find and Replace in Excel: Full Guide (2023)

    How to Use Find and Replace in Excel: Full Guide (2023)

    Find and Replace is one of the most common yet most resourceful features of Excel.

    Searching through hundreds of thousands of rows is definitely not the best thing to do. And to replace something within these rows is even worse.

    So Find and Replace lets you find a particular word or phrase in seconds regardless of the volume of the data.

    It surely is one of the most needed functions of Excel. If you are yet to use this feature, jump right into the guide below to know all about it 🧐

    You can also download our sample workbook for this article here if you want to practice along.

    How to use Find and Replace

    Using the Find and Replace feature is pretty simple. Press CTRL F to open the dialog box. Or select it from the Editing group.

    Excel displays the find and replace options.

    We have the following example data.

    Example data set on the active worksheet.

    Suppose we want to find Emily, the name of an employee working in a company. To do that, we will enter her name in the Find dialog box as:

    Using the find Tab to find a name.

    Once you type the name, press Enter. Excel will highlight the cell containing the result.

    All search results shown in a list.

    Pro Tip!

    Note that the name isn’t capitalized here. That’s because, in the find feature, capitalization doesn’t matter 😉

    The Find Next button moves you to the next instance containing the search item by highlighting the cell.

    The Find All button shows a list of all the occurrences where the search item occurs. Like this:

    Results shown in free Excel sheet

    You can then choose whichever value you want, and it will direct you to the cell.

    If you want to view all the cells at the same time, press CTRL A or manually select the entire list. Excel will highlight all the cells simultaneously:

    Results shown in free Excel sheet

    Replace data with Find and Replace

    Now, let’s see how the replace function works

    Suppose we want to find the position of Accountant in this data. And replace it with Auditor.

    To do this:

    1. Select Replace tab from the Find and Replace dialog box. Or press CTRL H. You can also open it from the Find & Select option under the Editing group.
    Using the replace window.
    1. Enter the search term in the Find what box.
    2. Type in the new term you want to replace the search term with.
    Text to replace search item with.
    1. Press Enter.
    Text replaced.

    Note that we entered capitalized search terms. That’s because Replace needs to locate the exact text string. And then replace it with some other term.

    Kasper Langmann, Microsoft Office Specialist

    Similar to the Find feature in Excel, Replace tab also has the Replace Next and Replace all options.

    The Replace Next option replaces each search term one by one.

    The Replace next option only replaced one entry.

    The Replace All replaces all the terms in one go. And displays a message confirming all the replacements have been made.

    Excel makes all the replacements. question mark.

    And that’s how you use the Find and Replace feature. Pretty easy, no? 😀

    Advanced settings of Find and Replace

    Now that you know all the basics of Find and Replace, let’s look at some advanced features it has to offer.

    To open the advanced functions of the Find feature, click the Options button in the dialog box.

    Choosing Options button.

    It displays a wide variety of options to choose from.

    The option button shows a plethora of information.

    Note that the list of options for the Find and Replace tab is the same. The only difference is that in Replace tab, you get an additional format option for the replace box.

    Let’s study all these options in detail below.

    Format: The format option lets you specify the format of the search item. Click the Format option at the top to select a format.

    Selecting the Format option.

    You can also choose the format for your text string from a particular cell. For that,

    1. Click on the drop-down arrow next to Format.
    2. Delete the existing format by clicking “Clear Find Format.”
    Clearing Find format
    1. Click “Choose Format From Cell”
    Choose format from cell.

    The cursor appears with a dropper.

    Just click on the cell whose format you want to copy, and click Replace all. The dialog box also shows a *Preview*.

    Find Tab shows preview

    Within: The within option lets you search a specific text string throughout the entire workbook 😵

    So even if you don’t remember where a certain piece of text is in your workbook, you can simply search for it. This feature is actually very helpful when you have to search for a single term from extensive data.

    Match Case: The match case option enables case sensitivity. This means that Excel will search for a specific term with the exact capitalization used.

    Say we search “hr” in lowercase instead of uppercase and put a checkmark on the ‘Match Case’ option.

    Lowercase position

    Press Find Next.

    Excel will show a warning message because we didn’t capitalize the position properly.

    Excel warning message.

    If we write the same search term in uppercase, Excel searches and shows the result as:

    Match case showed the exact result.

    Isn’t that amazing? 🤩

    Search: The search option lets you select the order in which you want to search.

    Search options.

    If you want to look for the search item row by row, select “by row”. And if you want to search column by column, select the “by column” option.

    Match Entire Cell Contents: This option restricts Find and Replace to look only for characters you have entered in the box. If you even miss a period, Excel will show a warning message.

    Say, we put a checkmark on the ‘Match entire cell contents‘ option. And type in the name “John,” whereas, in the data set, the correct name is “John O.

    This is what will happen:

    Excel warning message.

    And if we add “O.” to the same box, the result becomes:

    Adding the correct name.

    Excel returns the correct result. This tool is great if your spreadsheet contains a large amount of data.

    Look-in: The look-in option lets you specify the type of data of your search item.

    The Find tab offers three types, namely, Formulas, Values, and comments. The Replace tab, on the other hand, uses only one type of data, i.e., Formulas.

    If you only want to look for formulas, you can find them using the Go To Special option from Find & Select.

    Go to Special to replace text and formulas

    It offers a plethora of options and you can set the options as per your choice. You can use it to find other items too.

    Formulas option similar to wildcard characters.

    Just select the options and Excel will automatically apply them on your next search.

    That’s it – Now what

    And Tada! That’s how easy and fun it is to use Excel’s Find and Replace tools 🤗

    Not only can you find and replace a particular text string in seconds, but you can also specify its format, location, order, and case sensitivity.

    Undoubtedly, the Find and Replace feature of Excel is very powerful. But if you want to become an Excel master, there’s so much more you need to learn.

    If you are new to this spreadsheet software, we suggest you begin learning Excel’s built-in functions; IF, SUMIF and VLOOKUP.

    You can learn these superb functions for FREE in my 30-minute Excel course sent straight to your inbox.

    Other resources

    The Find and Replace feature in Excel is great. Especially when it comes to making tweaks and narrowing down your search criteria.

    The function is easy to understand and use. But with a little more practice, you will be able to master this and make large-scale changes in your data in seconds.

    If you like this article, we are sure you’d love to read more. Some related articles include the SEARCH, FIND, REPLACE and SUBSTITUTE functions in Excel.

    Frequently asked questions

    Frequently asked questions

    You can launch the Find and Replace dialog box by pressing CTRL + F.

    Or you can find it in the Find & Select Menu under the Editing group from the Home Tab. If you want quick access to the Replace feature, you can use the keyboard shortcut CTRL + H.

    If you prefer using formulas to find and replace items in Excel, you should try the SUBSTITUTE function. It is used when you know the exact characters of the text to be replaced. SUBSTITUTE function is a good alternative to Replace.

    Kasper Langmann2023-01-19T12:05:02+00:00

    Page load link

    Skip to content

    Поиск и замена в Excel с помощью регулярных выражений

    В этом руководстве показано, как быстро добавить пользовательскую функцию в свои рабочие книги, чтобы вы могли использовать регулярные выражения для замены текстовых строк в Excel.

    Когда дело доходит до замены одного фрагмента текста другим, Microsoft Excel предоставляет ряд опций на выбор, включая инструмент «Найти и заменить» и несколько текстовых функций замены. Зачем кому-то усложнять ситуацию с помощью регулярных выражений? Но дело в том, что стандартные функции Excel могут обрабатывать только ту строку текста, которую вы явным образом укажете. Чтобы найти строку, соответствующую некоторому шаблону, и заменить ее чем-то другим, необходимы регулярные выражения.

    Вот о чем мы будем говорить в этой статье:

    • Функция замены при помощи регулярных выражений Excel VBA
    • Замена текста, соответствующего шаблону
    • Замена чисел в тексте
    • Заменить денежные суммы
    • Поиск и замена всех совпадений
    • Замена определенного по счёту экземпляра
    • Поиск и замена в Excel с помощью Regex Tools

    Регулярное выражение – это шаблон, состоящий из последовательности символов, который можно использовать для поиска соответствующих символов в тексте.

    Функция замены при помощи регулярных выражений Excel VBA

    Как известно, встроенные функции Excel не поддерживают регулярные выражения. Чтобы иметь возможность использовать регулярные выражения в своих формулах, вам нужно создать собственную функцию. К счастью, объект RegExp уже существует в VBA, и мы используем этот объект в приведенном ниже коде:

    
    Public Function RegExpReplace(text As String, pattern As String, text_replace As String, Optional instance_num As Integer = 0, Optional match_case As Boolean = True) As String
        Dim text_result, text_find As String
        Dim matches_index, pos_start As Integer
     
        On Error GoTo ErrHandle
        text_result = text
        Set regex = CreateObject("VBScript.RegExp")
     
        regex.pattern = pattern
        regex.Global = True
        regex.MultiLine = True
     
        If True = match_case Then
            regex.ignorecase = False
        Else
            regex.ignorecase = True
        End If
     
        Set matches = regex.Execute(text)
     
        If 0 < matches.Count Then
            If (0 = instance_num) Then
                text_result = regex.Replace(text, text_replace)
            Else
                If instance_num <= matches.Count Then
                    pos_start = 1
                    For matches_index = 0 To instance_num - 2
                        pos_start = InStr(pos_start, text, matches.item(matches_index), vbBinaryCompare) + Len(matches.item(matches_index))
                    Next matches_index
     
                    text_find = matches.item(instance_num - 1)
                    text_result = Left(text, pos_start - 1) & Replace(text, text_find, text_replace, pos_start, 1, vbBinaryCompare)
                End If
            End If
        End If
     
        RegExpReplace = text_result
        Exit Function
     
    ErrHandle:
        RegExpReplace = CVErr(xlErrValue)
    End Function

    Добавьте этот код VBA в вашу рабочую книгу.

     Советы:

    • Если у вас мало опыта работы с VBA, это руководство проведет вас через процесс: Как создать пользовательскую функцию VBA в Excel .
    • После добавления кода не забудьте сохранить файл как книгу с поддержкой макросов (.xlsm).

    Синтаксис RegExpReplace

    Функция RegExpReplace ищет во входной строке значения, соответствующие регулярному выражению, и заменяет найденные совпадения указанным вами текстом.

    Функция принимает 5 аргументов, но обязательными являются только первые три.

    RegExpReplace(текст; шаблон; text_replace; [instance_num]; [match_case])

    Где:

    • Текст (обязательно) — текстовая строка для поиска.
    • Шаблон (обязательно) — регулярное выражение для сопоставления.
    • Text_replace (обязательно) — текст для замены найденных совпадающих подстрок.
    • Instance_num (необязательно) — порядковый номер, указывающий, какой из найденных экземпляров заменить. Если его не указать, функция заменит все найденные совпадения (по умолчанию).
    • Match_case (необязательный) — определяет, следует ли учитывать или же игнорировать регистр букв. Если значение ИСТИНА или опущено (по умолчанию), при поиске учитывается регистр; если ЛОЖЬ – то поиск совпадений происходит без учета регистра.

    Функция работает во всех версиях Excel от 365 до 2010.

    Полезные советы по использованию

    Чтобы убедиться, что ваши результаты оправдают ваши ожидания, давайте подробнее рассмотрим внутреннюю механику  поиска и замены:

    1. По умолчанию функция работает в режиме Заменить все. Чтобы заменить конкретное вхождение, поместите соответствующий номер в аргумент instance_num.
    2. По умолчанию функция чувствительна к регистру. Для поиска без учета регистра задайте для аргумента match_case значение ЛОЖЬ.
    3. Когда вы указываете регулярное выражение непосредственно в формуле, не забудьте заключить его в двойные кавычки (так как это текст).
    4. Если допустимый шаблон не найден, функция вернет исходное содержимое без изменений.
    5. Если регулярное выражение записано вами неверно, произойдет ошибка  #ЗНАЧ!.

    Примеры регулярных выражений для поиска и замены в Excel

    Предполагая, что вы уже вставили функцию RegExpReplace в свою книгу, давайте перейдем к более интересным вещам — использованию регулярных выражений для расширенного поиска и замены в Excel.

    Замена строки, соответствующей шаблону

    В приведенном ниже примере набора данных предположим, что вы хотите скрыть некоторые личные данные, такие как номер телефона. Учитывая, что это семизначное число в формате «000-00-00», для его нахождения мы используем следующее регулярное выражение.

    Шаблон: d{3}-d{2}-d{4}

    Для замены используется эта строка:

    Текст замены : ХХХ-ХХ-ХХ

    С исходной строкой в ​​A5 полная формула принимает следующий вид:

    =RegExpReplace(A5; «d{3}-d{2}-d{2}»; «XXX-XX-XX»)

    Для удобства вы можете ввести шаблон и замещающий текст в отдельные ячейки и ссылаться на эти ячейки в формуле. Если вы планируете использовать формулу для нескольких ячеек, не забудьте зафиксировать адреса ячеек знаком $ :

    =RegExpReplace(A5; $A$2; $B$2)

    Замена чисел в тексте

    Чтобы найти любую цифру от 0 до 9, используйте d в своем регулярном выражении. Чтобы найти определенные цифры, используйте соответствующий квантификатор или создайте более сложное регулярное выражение, как показано в примерах ниже.

    Заменить все числа

    Чтобы заменить при помощи регулярного выражения абсолютно все числа в строке каким-либо символом или текстом, используйте квантификатор +, говорящий о поиске чисел, содержащих одну или более цифр.

    Шаблон : d+

    Например, чтобы заменить все числа в ячейке A5 звездочкой, используйте следующую формулу:

    =RegExpReplace(A5; «d+»; «*»)

    Заменить суммы денег

    Предположим, что в том же наборе данных вы хотите заменить только суммы денег, а не все числа. 

    Шаблон : ‘($d+.?d{0,2}b)|(₽d+.?d{0,2}b)|(d+.?d{0,2}₽)

    Это регулярное выражение ищет и заменяет денежные величины вида $100, ₽100 и 100₽. Естественно, вы можете использовать и другие обозначения валюты платежа.

    Вы ищете знак доллара или рубля, за которым следует одна или несколько цифр $d+ — эта часть соответствует единице доллара, ₽d+ означает соответственно рубли. После основной единицы может быть или не быть дробной единицы. Чтобы соответствовать ему, вы ищете ноль или один знак десятичного разряда (точку), после которого идут от 0 до 2 цифр .?d{0,2}. Граница слова b в конце гарантирует, что совпадающее значение не является частью большего числа.

    Третья часть выражения ищет цифры, после которых могут быть (или не быть) два десятичных знака, и затем – знак рубля.

    Подставьте это регулярное выражение в нашу пользовательскую функцию, и вы получите следующий результат:

    =RegExpReplace(A5; «‘($d+.?d{0,2}b)|(₽d+.?d{0,2}b)|(d+.?d{0,2}₽)»; «*»)

    На скриншоте вы видите, как регулярное выражение помогло заменить денежные единицы звёздочками.

    Поиск и замена всех совпадений

    В классических регулярных выражениях есть глобальный флаг поиска /g, который заставляет регулярное выражение находить все возможные совпадения в строке. В VBA этот флаг не поддерживается. Вместо этого объект VBA RegExp предоставляет свойство Global, которое определяет, следует ли искать все вхождения или только первое. 

    В коде нашей функции для свойства Global установлено значение True, что означает, что шаблон должен проверяться на все возможные совпадения в строке.

    Итак, что вы делаете, чтобы заменить все вхождения, соответствующие шаблону? Ничего особенного. Это поведение реализовано по умолчанию. Вы в этом можете убедиться, еще раз внимательно взглянув на пример выше. В тексте заменены все подходящие комбинации символов, а не только первое вхождение.

    Замена определенного по счёту экземпляра

    Чтобы заменить только одно вхождение, соответствующее заданному шаблону, определите нужный порядковый номер в аргументе instance_num.

    Предположим, что вы хотите заменить только второй номер телефона, указанный у сотрудника. Поэтому в четвертом аргументе указываем 2.

    =RegExpReplace(A5; $A$2; $B$2; 2)

    Где $A$2 — шаблон регулярного выражения, а $B$2 — замещающий текст.

    Как видно на скриншоте выше, второй телефон успешно заменён.

    Поиск и замена в Excel с помощью Regex Tools

    Вы слышали о недавнем дополнении к Ultimate Suite? Я имею в виду четыре мощных инструмента регулярных выражений , представленных в последней версии. По сравнению со своими аналогами VBA функции Ablebits Regex имеют два основных преимущества:

    • Вы можете использовать регулярные выражения в обычных книгах .xlsx без необходимости вставлять какой-либо код или включать макросы в Excel.
    • Обрабатываемые стандартным механизмом .NET RegEx, эти функции поддерживают полнофункциональные классические регулярные выражения и преодолевают многие ограничения VBA RegExp.

    Функция AblebitsRegexReplace ищет совпадение с указанным регулярным выражением в ячейке и заменяет его указанными символами.

    Синтаксис ее совершенно такой же, как у функции RegExpReplace, а вот возможности немного другие.

    Ниже вы найдете пример замены регулярных выражений, который нельзя выполнить с помощью VBA.

    Допустим, вы хотите заменить текст в квадратных скобках каким-либо символом или строкой. Задача может быть выполнена либо с помощью группы захвата, либо с помощью позитивного осмотра. Первый способ проще, поэтому мы будем придерживаться его.

    Как правило, чтобы найти символ, который используется как часть шаблона в регулярных выражениях, вам нужно поставить перед ним обратную косую черту. В регулярных выражениях действует как escape-символ, который отменяет «особое» назначение следующего символа и превращает его в обычный символ. Таким образом, чтобы найти квадратную скобку, вы ставите перед ней обратную косую черту: [ для соответствия открывающей скобке и ] для соответствия закрывающей скобке. Между скобками поместите группу символов для поиска. В зависимости от того, какой квантификатор вы используете в группе, будут производиться разные замены.

    Жадный шаблон: [(.*)]

    Этот шаблон выполняет жадный поиск — захватывает как можно больше знаков. В начале ищем открывающую скобку [. Выражение .* соответствует как можно большему числу символов. Итак, этот шаблон захватывает все от первой открывающей скобки до последней закрывающей скобки ].

    Ленивый шаблон: [(.*?)]

    Этот шаблон выполняет ленивый поиск — захватывает как можно меньше. Ищем открывающую скобку ]. Знак вопроса ? заставляет .* искать совпадение с как можно меньшим количеством символов, пока не найдется следующее совпадение в шаблоне, то есть закрывающая скобка ]. Таким образом, этот шаблон захватывает все, от первой открывающей скобки до первой закрывающей скобки.

    Отрицание: [([^]]*)]

    Еще один способ найти подходящую подстроку в квадратных скобках — использовать оператор отрицания (^) внутри захватываемой группы. Начиная с первой открывающей скобки этот шаблон захватывает любые символы, кроме закрывающей скобки, пока не найдет первую закрывающую скобку. Результат будет таким же, как и при ленивом поиске.

    Как только вы определились с регулярным выражением, «скормите» его функции замены. Вот как:

    1. На вкладке Ablebits Data в группе Text щелкните Regex Tools .
    2. На панели Regex Tools настройте параметры
    3. Выберите исходные строки.
    4. Введите свой шаблон.
    5. Выберите параметр Replace with (Заменить на) и вставьте замещающий текст в поле.
    6. Чтобы результаты отображались в виде формул, а не значений, установите флажок Insert as a formula (Вставить как формулу) .
    7. Нажмите кнопку Replace (Заменить) .

    Чтобы результаты отображались в виде формул, а не значений, установите флажок Insert as a formula (Вставить как формулу) .

    Нажмите кнопку Replace (Заменить) .

    После этого функция AblebitsRegexReplace вставляется в новый столбец справа от исходных данных.

    =AblebitsRegexReplace(A2; «[(.*)]»; «*»)

    Шаблон поиска и замещающий текст вы можете сохранить в отдельных ячейках и указывать соответствующие ссылки на них. В нашем случае мы вводим шаблоны в ячейки B2 и C2, вводим значение замены в A2, затем сравниваем результаты и выбираем желаемый результат:

    Советы и примечания:

    • Функция AblebitsRegexReplace находит и заменяет все совпадения.
    • Функцию можно вставить непосредственно в ячейку через стандартное диалоговое окно «Вставить функцию», где она относится к категории AblebitsUDFs .

    Вот каким образом можно найти и заменить текстовые строки в Excel с помощью регулярных выражений. Я благодарю вас за чтение и с нетерпением жду встречи с вами в нашем блоге!

    What is Find and Replace Feature in Excel?

    The Find and Replace feature of Excel looks for a data value and replaces it with another data value. This data value can be a text string, number, date or special character. The Find and Replace feature can search within a worksheet or workbook, by rows or columns, and within formulas, values or comments.

    For example, in a financial report of Excel, the text string “asset” may need to be replaced with “assets.”

    The purpose of using the Find and Replace feature in Excel is to locate certain information in a database. It also allows modifying the existing data values with a few clicks. By default, the Find and Replace excel feature looks for a partial match. But, it can also look for an exact match if the option “match entire cell contents” is selected.

    Table of contents
    • What is Find and Replace Feature in Excel?
      • How to Access the Find and Replace Feature of Excel?
        • Example #1–Find a Partial Match in a Worksheet
        • Example #2–Find a Partial Match in a Workbook
        • Example #3–Find an Exact Match in a Workbook
        • Example #4–Replace the Range Reference of a Formula
        • Example #5–Replace the Existing Text to Make Two Strings Identical
        • Example #6–Replace the Old Formatting of a Cell
        • Example #7–Find a Comment in a Worksheet
      • The Key Points Related to the Find and Replace Feature of Excel
      • Frequently Asked Questions
      • Recommended Articles

    How to Access the Find and Replace Feature of Excel?

    The shortcuts to the Find and Replace excel feature are stated as follows:

    • “Ctrl+F” opens the Find tab of the Find and Replace feature.
    • “Ctrl+H” opens the Replace tab of the Find and Replace feature.

    Alternatively, the “find” and “replace” options can be clicked from the “find & select” drop-down (“editing” group) of the Home tab. These options open the Find and Replace tabs of the Find and Replace feature of Excel.

    Let us consider some examples to understand the working of the Find and Replace feature of Excel.

    You can download this Find and Replace Excel Template here – Find and Replace Excel Template

    Example #1–Find a Partial Match in a Worksheet

    The following image shows two worksheets titled “Jan” and “Feb.” These worksheets contain datasets that report the sales made (column C) to different customers (column B) in January and February.

    The names of the products, cost of goods sold (COGS), profits, and regions are also displayed in columns A, D, E, and F respectively. A similar dataset (with different numbers) is in columns H to M as well.

    Find the name “Mitchel” in the worksheet “Jan.” Use the Find and Replace feature of Excel.

    find and replace example

    The steps to use find and replace function in excel is follows:

    1. Go to the worksheet “Jan.” Next, press the keys “Ctrl+F” together. The Find tab of the “find and replace” dialog box opens. This is shown in the following image.

      Note: By default, Excel searches in the currently active worksheet.

      how to find example 3

    2. Type the word to be searched in the “find what” box. We type “Mitchel.”

      Note that this search is not case-sensitive. So, even if the worksheet contains “MITCHEL,” it will show up in the search results.

      how to find example 4

    3. Press either the “Enter” key or the “find next” option. The first occurrence of the name “Daniel Mitchel” is selected. So, cell B7 is selected, as shown in the following image. Clicking “find next” again and again selects the subsequent occurrences of “Mitchel.”

      Notice that though we entered “Mitchel” in the “find what” box, Excel has selected the name “Daniel Mitchel.” This is called a partial match. It implies that if there are any additional words preceding or succeeding the search value, the entire string containing the search value is returned in the result.

      how to find example 5

    4. Click “find all” to see all the strings containing “Mitchel.” The results are shown in the following image. These results display the following information:

      • The column “book” displays the name of the workbook containing the search value.
      • The column “sheet” displays the name of the worksheet containing the search value.
      • The column “cell” displays the reference of the cells containing the search value.
      • The column “value” displays the entire string containing the search value.

      Notice that at the bottom of the dialog box, Excel displays the number of cells containing the search value. In this case, there are 8 cells in the worksheet “Jan,” which contain either “Mitchel” or “Daniel Mitchel.”

      how to find example 6

    Difference between “find all” and “find next”: The “find all” option shows all the occurrences of the search value. Further, clicking any of the entries shown by this option takes the user to the corresponding cell.

    The “find next” option helps scan through the different cells containing the search value. Clicking “find next” for the first time selects the first occurrence of the search value. Likewise, clicking “find next” the second time selects the second occurrence of the search value, and so on.

    Example #2–Find a Partial Match in a Workbook

    Working on the dataset of example #1, find the name “Mitchel” in the entire workbook. Use the Find and Replace feature of Excel.

    The steps to search the stated string in the entire workbook are listed as follows:

    Step 1: Press the keys “Ctrl+F” together. The Find tab of the “find and replace” window opens. Type the name “Mitchel” in the “find what” box.

    Next, click “options,” shown within a black box in the following image.

    Find Word in Entire Workbook 1

    Step 2: Clicking “options” expands the “find and replace” dialog box. Click the drop-down next to the option “within” and select “workbook.”

    The selection is shown in the following image.

    Find Word in Entire Workbook 2

    Step 3: Click “find all” to see all the results. The results are shown in the following image. This time the string “Mitchel” has been found in 16 cells of the workbook.

    Clicking any of the entries will select the respective cell.

    Find Word in Entire Workbook 3

    Example #3–Find an Exact Match in a Workbook

    Working on the dataset of example #1, find an exact match of “Mitchel” in the entire workbook. Use the Find and Replace feature of Excel.

    The steps to search the exact name in the entire workbook are listed as follows:

    Step 1: Press the keys “Ctrl+F.” In the Find tab of the “find and replace” window, perform the following tasks:

    • Click “options” to expand the “find and replace” window.
    • Enter the name “Mitchel” in the “find what” box.
    • Select “workbook” in the box adjacent to “within.”
    • Select the checkbox of “match entire cell contents.”
    • Leave the “search” and “look in” parameters to default values which are “by rows” and “formulas” respectively.

    The name of the “find what” box and the selections are shown in the following image.

    Note: When the option “match entire cell contents” is selected, the Find and Replace excel feature looks for exactly those data values that have been entered in the “find what” box.

    Find exact word in entire workbook 1

    Step 2: Click “find all” to view all the exact matches of the name “Mitchel.” In the current workbook, 8 cells contain the exact name.

    The results (shown in the following image) display the cell references, exact value, and the names of the worksheet and the workbook.

    Find exact word in entire workbook 2

    Example #4–Replace the Range Reference of a Formula

    The following image shows the names (column A), salaries per annum (in $ in column B), salaries per month (in $ in column C), and departments (column D) of some employees of an organization.

    The total salary per annum is shown in cell G3. This sum incorrectly considers the range B2:B10 in place of the range B2:B22. Rectify the range of the formulas in cells G3 and H3 so that the total salary per annum is calculated accurately. Use the Find and Replace feature of Excel.

    Combination of FIND & REPLACE 1

    The steps to edit a formula by using the Find and Replace feature of Excel are listed as follows:

    Step 1: Copy the SUMThe SUM function in excel adds the numerical values in a range of cells. Being categorized under the Math and Trigonometry function, it is entered by typing “=SUM” followed by the values to be summed. The values supplied to the function can be numbers, cell references or ranges.read more formula of cell G3. For this, perform the given tasks:

    • Select cell G3. The formula [=SUM(B2:B10)] appears in the formula bar.
    • Copy this formula by pressing the keys “Ctrl+C” together.
    • Press the Escape (Esc) key once the formula has been copied. This will help exit the formula bar.

    Alternatively, copy the formula of cell H3 by pressing the keys “Ctrl+C.” Next, press “Ctrl+H.”

    Step 2: The Replace tab of the “find and replace” window opens. Paste the copied formula in the “find what” box, as shown in the following image. For pasting the formula, press the keys “Ctrl+V” together.

    Note: Instead of copying and pasting, one can type the formula directly in the “find what” box.

    Combination of FIND & REPLACE 2

    Step 3: Enter the correct formula in the “replace with” box. So, type the formula “=SUM(B2:B22)” without the beginning and ending double quotation marks. This is shown in the following image.

    Next, click “replace all.”

    Step 4: Click “Ok” in the message stating the number of replacements made. The formulas of cells G3 and H3 change from “=SUM(B2:B10)” to “=SUM(B2:B22).” As a result, the total salary per annum changes.

    The new output is shown within a red box in the following image. Hence, the total salary paid to the given 21 employees is $11,179,954 per annum.

    Example #5–Replace the Existing Text to Make Two Strings Identical

    There are two images titled “image 1” and “image 2.” Both images are in different worksheets. Further, the following information is given:

    • Image 1 shows the product code (column A) and prices (in $ in column B) of 21 products of a multinational organization.
    • Image 2 shows the product code (column A) and a blank column (column B) for the prices of the 21 products.

    Notice that the product codes of both images consist of some letters prefixed to a number. The letters are different in both images, but the subsequent numbers are the same.

    Make the product code identical in both images by using the Find and Replace feature of Excel. This will help fetch the prices of “image 1” in “image 2” (column B) with the VLOOKUP functionThe VLOOKUP excel function searches for a particular value and returns a corresponding match based on a unique identifier. A unique identifier is uniquely associated with all the records of the database. For instance, employee ID, student roll number, customer contact number, seller email address, etc., are unique identifiers.
    read more
    .

    Image 1

    Combination of FIND & REPLACE 5

    Image 2

    Combination of FIND & REPLACE 6

    The steps to make the product code identical by using the Find and Replace feature of Excel are listed as follows:

    Step 1: Press the keys “Ctrl+H” to open the Replace tab of the “find and replace” window.

    Step 2: Enter “pdc” in the “find what” box. Enter “prdct” in the “replace with” box. Next, click “replace all.” A message stating the number of replacements made is displayed. Click “Ok” to proceed.

    The entries and the outputs are shown in the following image. Now, one can easily apply the VLOOKUP function to fetch the prices in this image. Had the replacements not been made, the VLOOKUP function could not have been applied.

    Combination of FIND & REPLACE 7

    Difference between “replace all” and “replace”: The “replace all” option replaces all the occurrences of the search value in one go. In contrast, the “replace” option replaces one occurrence at a time.

    Therefore, use “replace” when not sure which occurrence needs to be replaced. Use “replace all” when all occurrences of the search value need to be replaced.

    Example #6–Replace the Old Formatting of a Cell

    The following image shows some departments of an organization. Cell A4 is in grey and cells B5, C2, and D5 are in blue. We want all the cells containing “marketing” to be in one color.

    Therefore, replace the grey color of cell A4 with blue color. Use the Find and Replace feature of Excel.

    FIND & REPLACE Format 1

    The steps to change the formatting with the Find and Replace feature of Excel are listed as follows:

    Step 1: Select the dataset whose formatting needs to be changed. We have selected the range A2:D6.

    Next, press the keys “Ctrl+H” to open the Replace tab of the “find and replace” window. In this tab, click “options” shown on the right side.

    This entire step is shown in the following image.

    FIND & REPLACE Format step 1

    Step 2: Once “options” is clicked, the “find and replace” window expands. Click the drop-down arrow of the first “format” option (to the right of the “find what” box). Next, select “choose format from cell.”

    The selection is shown within a black box in the following image.

    FIND & REPLACE Format step 2

    Step 3: Select the cell whose formatting needs to be changed. We select cell A4. As a result, the “no format set” on the left of “format” changes to “preview.” This “preview” option reflects the color of cell A4, as shown in the following image.

    Note: The “preview” option of the following image and cell A4 of the first image (at the beginning of this example) show a slight variation in color. Please ignore this variation, which may be due to different Excel versions being used to create images.

    FIND & REPLACE Format step 3

    Step 4: Click the drop-down arrow of the second “format” option (to the right of the “replace with” box). Select “choose format from cell” and click any of the blue cells (B5, C2 or D5). Consequently, the “preview” option appears in blue, as shown in the following image.

    Next, click “replace all.”

    FIND & REPLACE Format step 4

    Step 5: Excel shows the number of replacements made. Click “Ok” to proceed. The output is shown in the following image.

    Hence, cell A4 has also been colored blue. In this way, the formatting of a cell can be searched and replaced. So, we have searched for the grey color and replaced it with the blue color. Now, all cells containing “marketing” are in a single color.

    Note: Alternatively, one can select the “format” option from both the “format” drop-downs. Thereafter, from the respective “fill” tabs, select the color to be searched and the color to be replaced with.

    FIND & REPLACE Format step 5

    Example #7–Find a Comment in a Worksheet

    The following image contains two datasets (range A1:D11 and range A13:D23) that show the gross sales (column B), cost of goods sold (COGS in column C), and profits (column D) of ten products of an organization. Further, the following information is given:

    • Both datasets pertain to different time periods. The figures in brackets in column D are the losses suffered by the organization.
    • In both datasets, each cell of column D contains commentsIn Excel, Insert Comment is a feature used to share tips or details with different users working within the same spreadsheet. You can either right-click on the required cell, click on “Insert Comment” & type the comment, use the shortcut key, i.e., Shift+F2, or click on the Review Tab & select “New Comment”. read more. This is indicated by the small, red triangles at the top-right side of each cell.
    • There are three kinds of comments, namely, “no commission,” “commission @ 5%,” and “commission @ 10%.”

    Find the comment “no commission” in the current worksheet, which has been renamed “comment.” Use the Find and Replace feature of Excel.

    FIND Comments step 1

    The steps to search a specific comment by using the Find and Replace feature of Excel are listed as follows:

    Step 1: Open the Find tab of the “find and replace” dialog box. For this, press the keys “Ctrl+F” together. Next, click “options.” Make the following selections in this window:

    • Select “sheet” and “by rows” in the “within” and “search” parameters. These are the default selections of Excel.
    • Select the option “comments” from the drop-down of “look in.”

    The selection of the second pointer is shown within a black box in the following image.

    FIND Comments step 2

    Step 2: In the “find what” box, enter the string of the comment that needs to be searched. We have entered “no commission,” as shown in the following image.

    Next, click “find all.”

    FIND Comments step 3

    Step 3: The search results are shown in the following image. Notice that 13 cells (refer to the bottom of the image) contain the comment “no commission.”

    The references to cells containing the specific comment (no commission) are displayed in the column “cell.” The formulas (of column D) and the names of the workbook and worksheet are displayed in columns “formula,” “book,” and “sheet” respectively.

    Clicking any of the entries of these results will select the cell containing the comment.

    FIND Comments step 4

    The Key Points Related to the Find and Replace Feature of Excel

    The important points related to the Find and Replace feature of Excel are listed as follows:

    • The search can be limited to a specific range of the worksheet. For such restriction, select the range prior to opening the Find tab of the “find and replace” window. If no range is selected, Excel searches in the currently active sheet. If the search value cannot be found in the selected range or the active worksheet, a message stating the same is displayed.
    • The replacements can also be restricted to a specific region of the worksheet. For this, select the area (or range) prior to opening the Replace tab of the “find and replace” window. If no range is selected, Excel makes the replacements in the entire active sheet.
    • The Find and Replace excel feature can replace the existing formatting of cells with the new formatting. For this, make use of the two “format” drop-downs of the Replace tab.
    • The search value can be looked up in a protected worksheet, but a replacement cannot be made. For replacing, unprotect the sheet first.

    Frequently Asked Questions

    1. Define the Find and Replace feature and state how it is used in Excel.

    The Find and Replace feature of Excel helps search a data value and replace it with another data value. The need to search a data value arises when certain information is to be located in a database. The need to replace a data value arises when the existing information requires to be changed.

    The Find and Replace feature (or window) of Excel can be used in either of the following ways:

    • Use the Find tab when a data value needs to be searched. Specify the data value in the “find what” box and click “find next” or “find all” to search.
    • Use the Replace tab when one data value needs to be replaced by another. Specify the value to search and the value to replace with, in the “find what” and “replace with” boxes respectively. Click “replace” or “replace all” to make the replacements.

    Note: Click the “options” button to view more features of the “find and replace” window of Excel.

    2. How to use the Find and Replace feature with wildcards in Excel?

    The Find and Replace feature can be used with the wildcard characters like an asterisk (*), question mark (?), and tilde (~) in the following ways:

    The asterisk looks for any number of characters. For instance, “ro*” will find the strings rose, product, root, metro, rhinoceros, and so on. So, the words having “ro” anywhere in the string will be returned in the search results.
    • The question mark looks for a single character of the string. For instance, “s?m” will find the strings simplicity, sampling, similarity, blossom, troublesome, and so on. So, the words having any character between “s” and “m” (placed anywhere in the string) are returned in the search results.
    • The tilde looks for the actual asterisk, question mark or tilde in the strings. For instance, “~?” will find “happy?,” “mer?ry,” “?joyful,” “cheerful?”, and so on. So, the words having a question mark anywhere in the string are returned in the search results. Likewise, “~*” and “~~” look for words that contain asterisk or tilde at any place in the string.

    The wildcard characters stated in the preceding pointers [like “ro*,” “s?m,” “~?,” “~*,” or “~~”] need to be typed in the “find what” box. The value to be replaced with needs to be entered in the “replace with” box.

    Note: To look for an exact match, select the option “match entire cell contents.”

    3. How is the Find and Replace feature used for the following tasks of Excel?

    1. Replace a value with nothing
    2. Assign a format to specific cells

    1. The steps to replace a value with nothing are listed as follows:

    a. Open the Replace tab by pressing the keys “Ctrl+H.”
    b. Type the value to be replaced with nothing in the “find what” box.
    c. Leave the “replace with” box blank.
    d. Click the “replace all” button.

    All occurrences of the value typed in the “find what” box are deleted.

    2. The steps to assign a format to specific cells are listed as follows:

    a. Open the Replace tab by pressing the keys “Ctrl+H.”
    b. In the “find what” box, type the text string to be formatted.
    c. In the “replace with” box, type the same text string as that of the preceding step.
    d. Click “options.” The “find and replace” window expands.
    e. Click the “format” drop-down to the right of “replace with.” Select the option “format.” The “replace format” window opens.
    f. Assign the desired formatting in the “alignment,” “font,” “border,” and “fill” tabs.
    g. Click “Ok” in the “replace format” window. Click “replace all” in the “find and replace” window. Click “Ok ” in the message stating the number of replacements made.

    The new formatting will be assigned to the cells containing the “find what” string. Notice that no replacements of data values will be made. This is because the text of “find what” and “replace with” boxes are the same. So, there is only a change in the formatting of specific cells.

    Recommended Articles

    This has been a guide to Find and Replace in Excel. Here we discuss how to Find and Replace in Excel using the shortcut keys along with practical examples and downloadable Excel templates. You may also look at these useful functions of Excel–

    • How to Find and Select in Excel?Find and Select in Excel is a feature available on the Home Tab of Excel that facilitates the user to quickly discover a specific text or value in the given data. The shortcut key to instantly use this feature is Ctrl+F.read more
    • FIND VBA FunctionVBA Find gives the exact match of the argument. It takes three arguments, one is what to find, where to find and where to look at. If any parameter is missing, it takes existing value as that parameter.read more
    • Use FIND FunctionFind function in excel finds the location of a character or a substring in a text string. In other words it finds the occurrence of a text in another text, as it gives us the position, the output returned by this function is an integer.read more
    • Not Equal to in Excel“Not Equal to” argument in excel is inserted with the expression <>. The two brackets posing away from each other command excel of the “Not Equal to” argument, and the user then makes excel checks if two values are not equal to each other.read more

    Понравилась статья? Поделить с друзьями:
  • Excel replace all cells with text
  • Excel repack by kpojiuk
  • Excel removing duplicates column
  • Excel removing all formatting
  • Excel remove table formatting