How to find and replace values greater than / less than a specific value in Excel?
Maybe, there are multiple data in your worksheet, now, you want to find all the cells which contain the value greater than or less than a specific number, and then replace them with another value you need at once. The normal Find and Replace feature is not applied to solve this problem, do you have any other good suggestions to deal with this task?
Find and select specific cells and then replace them with another value:
Kutools for Excel’s Select Specific Cells feature can help you find and select the specific cells, and then you can replace them with other value or do some formatting for the selected cells you need. Free Download Kutools for Excel Now.
Kutools for Excel: with more than 200 handy Excel add-ins, free to try with no limitation in 60 days. Download and free trial Now!
For example, I will find all the values which greater than 500, and replace them with 0.
The following VBA code can help you to replace the values which greater or less than a specific value at one, please do as follows:
1. Hold down the ALT + F11 keys, and it opens the Microsoft Visual Basic for Applications window.
2. Click Insert > Module, and paste the following code in the Module Window.
VBA code: Find and replace values greater or less than a specific value
Sub FindReplace() 'Update 20150423 Dim Rng As Range Dim WorkRng As Range On Error Resume Next xTitleId = "KutoolsforExcel" Set WorkRng = Application.Selection Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8) For Each Rng In WorkRng If Rng.Value > 500 Then Rng.Value = 0 End If Next End Sub
3. Then press F5 key to run this code, and select the range data that you want to replace from the prompt box, see screenshot:
4. And then click OK, and you can see all the values greater than 500 have been replaced with 0.
Note: In the above code, you can change the following variables to your desired.
If you are not familiar with the code, I can talk about a handy tool- Kutools for Excel, with its Select Specific Cells feature, you can quickly select the cells that you need, and then replace them at once.
|Kutools for Excel : with more than 300 handy Excel add-ins, free to try with no limitation in 60 days.|
After installing Kutools for Excel, do as following steps:
1. Select the data range that you want to find and replace.
2. Click Kutools > Select > Select Specific Cells, see screenshot:
3. In the Select Specific Cells dialog box, click Cell option under Selection type, and choose Greater than from the Specific type drop down, and enter the value you want to use in the text box besides Greater than, see screenshot:
4. Then click OK button, all the cells greater than 500 have been selected immediately, then enter the value you need to replace with, and press Ctrl + Enter keys together, all the selected values have been replaced at the same time. See screenshots:
Note: In the Select Specific Cells dialog box, you can use other criteria, such as Less than, Equals, Contains, and so on.