I am trying to loop through a database that has been autofiltered. My problem is that the rows that are not visible are still selected by my loop. Any thoughts on how to select only the filtered data?
Thanks
I am trying to loop through a database that has been autofiltered. My problem is that the rows that are not visible are still selected by my loop. Any thoughts on how to select only the filtered data?
Thanks
You can use the entirerow = hidden property, like this
Sub Macro1()
Dim R As Range
Dim Row As Range
Dim i As Integer
Set R = ActiveSheet.Range("A1").CurrentRegion
Set R = R.Offset(1, 0).Resize(R.Rows.Count - 1, R.Columns.Count)
For i = 1 To R.Rows.Count
If Not R.Rows(i).EntireRow.Hidden Then
MsgBox "Row " & i + 1 & " is selected"
End If
Next i
End Sub
Display More
Hans
Don’t have an account yet? Register yourself now and be a part of our community!