Find and select cells between specific values in a range

How to find and select cells between specific values in a range using VBA

METHOD 1. Find and select cells between specific values in a range using VBA

VBA

Sub Select_between_specific_value()
'declare variables
Dim ws As Worksheet
Dim SelectCells As Range
Dim xcell As Object
Dim Rng As Range
Set ws = Worksheets("Analysis")
Set Rng = ws.Range("B3:C9")
'check each cell in a specific range if the criteria is matching
For Each xcell In Rng

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.
Range: Select the range that captures the cells in which you want to select the cells that are between specific values by changing the range reference ("B3:C9") in the VBA code.

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

EXPLANATION

EXPLANATION

This tutorial shows how to find and select cells that are between two specific values in a range, 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 selected range and select the cells that meet the criteria.

RELATED TOPICS

Related Topic Description Related Topic and Description
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
How to fill blank cells with a specific value using Excel and VBA methods