Skip to main content

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 replace values greater than / less than a specific value with VBA code

Find and replace values greater than / less than a specific value with Kutools for Excel


For example, I will find all the values which greater than 500, and replace them with 0.

doc replace greater than 1

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()
'Updateby Extendoffice
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:

doc replace greater than 2

4. And then click OK, and you can see all the values greater than 500 have been replaced with 0.

doc replace greater than 3

Note: In the above code, you can change the following variables to your desired.

  • If Rng.Value > 500 Then
  • Rng.Value = 0

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 30 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:

doc replace greater than 5

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:

doc replace greater than 6  2 doc replace greater than 7

Note: In the Select Specific Cells dialog box, you can use other criteria, such as Less than, Equals, Contains, and so on.

Download and free trial Kutools for Excel Now!


Kutools for Excel: with more than 300 handy Excel add-ins, free to try with no limitation in 30 days. Download and free trial Now!

Related articles:

How to find and replace exact match in Excel?

How to replace text with corresponding pictures in Excel?

How to find and replace fill color in Excel?

Best Office Productivity Tools

🤖 Kutools AI Aide: Revolutionize data analysis based on: Intelligent Execution   |  Generate Code  |  Create Custom Formulas  |  Analyze Data and Generate Charts  |  Invoke Kutools Functions
Popular Features: Find, Highlight or Identify Duplicates   |  Delete Blank Rows   |  Combine Columns or Cells without Losing Data   |   Round without Formula ...
Super Lookup: Multiple Criteria VLookup    Multiple Value VLookup  |   VLookup Across Multiple Sheets   |   Fuzzy Lookup ....
Advanced Drop-down List: Quickly Create Drop Down List   |  Dependent Drop Down List   |  Multi-select Drop Down List ....
Column Manager: Add a Specific Number of Columns  |  Move Columns  |  Toggle Visibility Status of Hidden Columns  |  Compare Ranges & Columns ...
Featured Features: Grid Focus   |  Design View   |   Big Formula Bar    Workbook & Sheet Manager   |  Resource Library (Auto Text)   |  Date Picker   |  Combine Worksheets   |  Encrypt/Decrypt Cells    Send Emails by List   |  Super Filter   |   Special Filter (filter bold/italic/strikethrough...) ...
Top 15 Toolsets12 Text Tools (Add Text, Remove Characters, ...)   |   50+ Chart Types (Gantt Chart, ...)   |   40+ Practical Formulas (Calculate age based on birthday, ...)   |   19 Insertion Tools (Insert QR Code, Insert Picture from Path, ...)   |   12 Conversion Tools (Numbers to Words, Currency Conversion, ...)   |   7 Merge & Split Tools (Advanced Combine Rows, Split Cells, ...)   |   ... and more

Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time.  Click Here to Get The Feature You Need The Most...

Description


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!
Comments (2)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
If only there was a way to do the same without losing formulas(
This comment was minimized by the moderator on the site
It's really awesome!!! I love it!
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations