PDA

View Full Version : Select Rows which has specific value (but now Entire Row selection)



Dancul
02-08-2019, 12:14 PM
Hi

I'm trying to find some solution for selecting rows where is some specific text or value in cell.

I use code below, which looks simple and is working, but what I want to figure is define somehow selection, I don't want to select entire row. For example I want select just from B to I range.
Does anybody have idea?



Sub SelectRowsIII()
'ACTIVE
Dim ocell As Range
Dim rng As Range
For Each ocell In Range("A1:A1000")
If ocell.Value = "x" Then
If rng Is Nothing Then
Set rng = ocell.EntireRow
Else
Set rng = Union(rng, ocell.EntireRow)
End If
End If
Next
If Not rng Is Nothing Then rng.Select
Set rng = Nothing
Set ocell = Nothing
End Sub





Regards

Kenneth Hobs
02-08-2019, 01:44 PM
If Not rng Is Nothing Then Intersect(rng.Rows, Columns("B:I")).Select

Dancul
02-10-2019, 02:31 AM
Working perfectly ,
thanks