Find Or Replace Text Excel

How to find and replace text then preserve formatting in Excel?

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 se. The reason being is that I have a formula and it wont work when the cell is in date format. I'd rather not do this without Find and Replace being that I have about 50+ worksheets and more dates to change into text format. Ive also tried to ctrl+f 42386 to Jan-17 and continues to stay as 42386. Or if I replace with any variation of Jan 17 it.

Find and Replace function is powerful and helpful when we need to find a specific value and replace it with another one. But if there is a range of cells, and some of the cells include different formatting values. In this case, to find and replace value by Find and Replace function will break the formatting of the values in cells as below screenshot shown, how can we preserve the formatting of values in each cell while finding and replacing in Excel?
Find and replace preserve formatting with Macro code

Find and replace preserve formatting with Macro code

There is no other methods but macro code can help you to find and replace text and preserve formatting.

1. Press Alt + F11 keys to open the Microsoft Visual Basic for Application window.

2. Click Insert > Module, and paste below code to the script.

VBA: Find and replace preserve formatting

3. Press F5 key, a dialog pops out for you to select a range to find and replace, see screenshot:

4. Click OK, and the specific string in the selected cell are replace with other and keep the formatting.

Tip: In the code, KK is the string you want to find, and Kutools is the string you want to replace with, you can change them as you need.

The Best Office Productivity Tools

Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%

  • Reuse: Quickly insert complex formulas, charts and anything that you have used before; Encrypt Cells with password; Create Mailing List and send emails...
  • Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
  • Merge Cells/Rows/Columns without losing Data; Split Cells Content; Combine Duplicate Rows/Columns... Prevent Duplicate Cells; Compare Ranges...
  • Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
  • Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
  • Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
  • Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
  • Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
  • More than 300 powerful features. Supports Office/Excel 2007-2019 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features 30-day free trial. 60-day money back guarantee.

Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Can you clarify if there is a solution that works in cells with more than 255 characters, or is this a limitation of Excel? Does your add-in support cells with more than 255 characters that contain formatting?
  • To post as a guest, your comment is unpublished.
    Same Question as John Birk i need a workaround with Cells that have more then 255 signs.
    • To post as a guest, your comment is unpublished.
      The method only work while characters less than 255 digits.
  • To post as a guest, your comment is unpublished.
    I am getting syntax error in VBA
  • To post as a guest, your comment is unpublished.
    I tried your solution on a cell that is over 255 characters long and nothing changes. Is there a workaround for this case?

How to use Replace function to replace and add string in Excel?

In Excel, we may use the Find and Replace function to find a string then replace with another one. But in many cases, the Find and Replace function cannot satisfy your request. Here I introduce how to use the Replace function to solve some problems in Excel.

Replace function

=REPLACE(text, start_num, num_chars, new_text)

Case 1 Replace character string in the specific location with other in a string

=REPLACE(text, startnum, numchars, newtext)

If you want to replace a character string in a specific location with another string as below screenshot shown,

you can do as this:

Select a cell which you will place the result and type=REPLACE(A1,3,3,'KTE'), and drag fill handle over the cells you use. See screenshot shown.

Case 2 Replace multiple character strings in multiple locations with others in a string

=REPLACE(REPLACE(text,stratnum,characternumber,'newtext'),startnum,characternumber,'newtext)

Find Or Replace Text Excel Function

If you want to replace multiple character strings in locations with other strings as below screenshot shown,

Do as this:

Select a cell which you will place the result and type =REPLACE(REPLACE(A7,7,1,'1'),15,1,'3'), drag fill handle over the cells you use. See screenshot shown.

Case 3 Replace year/mont/day in Date format

=REPLACE(TEXT(text, 'dd-mmm-yy'), 4, 3, 'newtext')

If you have a range of cells in the special date format 1-Oct-18, what you need is to replace the month to Nov as below screenshot shown,

Excel Vba Find And Replace Text In Column

Use this formula

Select a cell which you will place the result and type =REPLACE(TEXT(A14, 'dd-mmm-yy'), 4, 3, 'Nov'), drag fill handle over the cells you use. See screenshot shown.

Case 4 Convert number to date

=DATEVALUE(REPLACE(REPLACE(text,3,0,'/'),6,0,'/'))

If you want to convert text number to standard dates as below screenshot shown, do as this:

Select a cell which you will place the result and type =DATEVALUE(REPLACE(REPLACE(A21,3,0,'/'),6,0,'/')), drag fill handle over the cells you use, the format the cells as Short Date format. See screenshot shown.

Case 5 Replace character string with other in the string

=REPLACE(textreference, FIND('oldtext',textreference), numbercharacter, 'newtext')

If you want to replace a string with another in the string as below screenshot shown,

Find And Replace Text Excel 2016

Just use the Replace function and Find function

Select a cell which you place the result and type =REPLACE(A28, FIND('@abc',A28), 4, '@bca'), drag fill handle over the cells you use. See screenshot shown.

Tip: This formula only work for the first occurrence of string.

Case 6 Add new character into specific location of the string

=REPLACE(REPLACE(text,startnumber,0,'newtext'),startnumber,0,'newtext')

If you want to add new character into specific locations of a string as below screenshot shown.

Find And Replace Text Excel Formula

Just do as this

Select a cell which you will place the result and type =REPLACE(REPLACE(A34,4,0,'-'),8,0,'-'), drag fill handle over the cells you use. See screenshot shown.

The Best Office Productivity Tools

Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%

  • Reuse: Quickly insert complex formulas, charts and anything that you have used before; Encrypt Cells with password; Create Mailing List and send emails...
  • Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
  • Merge Cells/Rows/Columns without losing Data; Split Cells Content; Combine Duplicate Rows/Columns... Prevent Duplicate Cells; Compare Ranges...
  • Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
  • Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
  • Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
  • Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
  • Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
  • More than 300 powerful features. Supports Office/Excel 2007-2019 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features 30-day free trial. 60-day money back guarantee.
Find or replace text excel example

Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.