Find and select cells between specific values in a worksheet

How to find and select cells between specific values in an entire worksheet using VBA

METHOD 1. Find and select cells between specific values in an entire worksheet using VBA

VBA

Sub Select_between_specific_value()
'declare variables
Dim ws As Worksheet
Dim SelectCells As Range
Dim xcell As Object
Set ws = Worksheets("Analysis")
'check each cell in an entire worksheet if the criteria is matching
For Each xcell In ws.UsedRange.Cells

If xcell.Value >= 400 And Cell.Value <= 500 Then

If SelectCells Is Nothing Then
Set SelectCells = Range(xcell.Address)
Else
Set SelectCells = Union(SelectCells, Range(xcell.Address))
End If

End If

Next

'select the cells that are between the specified values
SelectCells.Select

End Sub

ADJUSTABLE PARAMETERS
Worksheet Selection: Select the worksheet which captures the range of cells in which you want to select the cells that are between the specific values by changing the Analysis worksheet name in the VBA code. You can also change the name of this object variable, by changing the name 'ws' in the VBA code.
Lower Value: Select the value that represent the lower of the two values, meaning that the values to be selected need to be greater than or equal to this value, by changing the value of "400" in the VBA code.
Upper Value: Select the value that represent the higher of the two values, meaning that the values to be selected need to be less than or equal to this value, by changing the value of "500" in the VBA code.

Explanation about how to find and select cells with specific value in a worksheet

EXPLANATION

EXPLANATION

This tutorial shows how to find and select cells that are between two specific values in a worksheet, using VBA. This is achieved by using an IF AND Statement and setting the criteria to be between the two specific values. The VBA code will then loop through each cell in the specified worksheet and select the cells that meet the criteria.

RELATED TOPICS

Related Topic Description Related Topic and Description
How to find and select cells between specific values in a range using VBA
How to find and select cells with specific value in a worksheet using Excel and VBA methods
How to find and select the cells with specific value in a selected range using Excel and VBA methods
How to find and replace the cells with specific value in a selected range using Excel and VBA methods
How to find and replace the cells with specific value in an entire worksheet using Excel and VBA methods