How to write Excel VBA code to select rows based on column values?

Need Excel VBA macro code snippet to select all rows where column A=1 and column D=3.5

thanks

Dim cell As Range
Dim myrows As String
For Each cell In Range("A1:A" & [A65536].End(xlUp).Row)
If cell.Value = 1 And cell.Offset(0, 3).Value = 3.5 Then
myrows = myrows & cell.EntireRow.Address & ","
End If
Next cell
myrows = Left(myrows, Len(myrows) – 1)
Range(myrows).Select

Leave a Reply