Check if there is autofiltered content

carddard

Active Member
Joined
Aug 19, 2008
Messages
427
After autofiltering, in VBA, how do I check if there are rows?

If there are rows I need to do a certain formula.. If there aren't, I would skip.

Please advise!

Thanks!
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Check the following example....
Add a command button from control box and paste following codes in code window
Code:
Private Sub CommandButton1_Click()
    Dim row As Integer, col As Integer
    row = 1
    col = 1
    'column A contains name
    'column B contains age
    'select records with age=23 if record found apply formula B + 1 in column C
    While Sheet1.Cells(row, col).Value <> ""
        If CInt(Sheet1.Cells(row, col + 1).Value) = 23 Then
            Sheet1.Cells(row, col + 2).Formula = "=B" & row & " + 1"
        End If
        row = row + 1
    Wend
    
End Sub

Hope this helps
 
Upvote 0
After autofiltering, in VBA, how do I check if there are rows?

If there are rows I need to do a certain formula.. If there aren't, I would skip.

Please advise!

Thanks!
Perhaps you could post your existing autofilter code?

... or at least tell us something about what range is being filtered?

Also, can you confirm that ...
how do I check if there are rows
... means "how do I check if there are visible rows after doing the AutoFilter"?
 
Upvote 0

Forum statistics

Threads
1,203,759
Messages
6,057,191
Members
444,913
Latest member
ILGSE

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top