Maybe I have found a solution but I can't get to it:
I have used the funcion IF to give the cells given value respect to the adiacent cell, then by using the following macro i select the values corresponding the right cell:
Option Explicit
Sub SelectByValue(Rng1 As Range, MinimunValue As Double, MaximumValue As Double)
Dim MyRange As Range
Dim Cell As Object
'Check every cell in the range for matching criteria.
For Each Cell In Rng1
If Cell.Value >= MinimunValue And Cell.Value <= MaximumValue Then
If MyRange Is Nothing Then
Set MyRange = Range(Cell.Address)
Else
Set MyRange = Union(MyRange, Range(Cell.Address))
End If
End If
Next
'Select the new range of only matching criteria
MyRange.Select
End Sub
Sub CallSelectByValue()
'Call the macro and pass all the required variables to it.
'In the line below, change the Range, Minimum Value, and Maximum Value as needed
Call SelectByValue(Range("E:E"), 1, 3)
End Sub
End Sub
What i need is that the macro also select the adiacent 3 cells to the right so that i can delete them an move the cells up! I've tried to use offset in the MyRange.Select but it only select the first entry!
Bookmarks