Article updated on June 29, 2018

This article explains how to substitute part of a formula across all cells in a worksheet. It is easier than you think, no VBA programming or formulas are needed.

The picture above demonstrates a simple example, the formula in cell B3 gets values below 5 from sheet 2 cell range B3:B12.

Array formula in cell B3

=SMALL(IF(Sheet2!$B$3:$B$12<5, Sheet2!$B$3:$B$12, ""), ROWS($A$1:A1))

I will now show you how to replace Sheet2 with Sheet3 in formulas, in all cells in Sheet1. Simply press CTRL and H to open the Find and Replace dialog box.

Click the "Options" button to see all settings.

Here you have the option to

  • Search the entire workbook or just the active worksheet. I want to search the active worksheet so I change nothing.
  • Match entire cell contents. Deselect the check box, I want to match specific strings in formulas.

Click in field "Find what:" and type Sheet2. Now click in field "Replace with:" and type Sheet3, then click on "Replace All" button.

This will find all instances of Sheet2 in all cells and replace them with Sheet3.

Click the "OK" button and then the "Close" button.

The array formula in cell B3 (Sheet1) changes to:

=SMALL(IF(Sheet3!$B$3:$B$12<5, Sheet3!$B$3:$B$12, ""), ROWS($A$1:A1))

Recommended article

Search all workbooks in a folder

Today I'll show you how to search all Excel workbooks with file extensions xls, xlsx and xlsm in a given folder for a […]

Replace part of formula in a specific cell range

Simply select the cell range, press CTRL + H to open the Find and Replace dialog box.

The "Find and Replace" action will now be applied to cell range B3:B4.

Replace n:th instance

Array formula in cell B3 (Sheet1)

=SMALL(IF(Sheet2!$B$3:$B$12<5, Sheet2!$B$3:$B$12, ""), ROWS($A$1:A1))

To replace only the first instance of a specific search string in the formula simply include more characters so it makes the search string unique.

Example, you want to replace Sheet2 with Sheet3 but only the first instance found in the formula.

Press CTRL + H to open the Find and Replace dialog box.

Don't forget to add the included characters in the "Replace with: " field as well.

String IF(Sheet2 is found in only one location in each cell, this will replace only the first instance of Sheet2.

=SMALL(IF(Sheet3!$B$3:$B$12<5, Sheet2!$B$3:$B$12, ""), ROWS($A$1:A1))