You're welcome Tony. I'm glad to have been able to assist.
Generally, using the Autofilter within a "With" statement, should negate the need for a check. A couple of examples follow:-
Sub FilterIt()
Application.ScreenUpdating = False
Dim sws As Worksheet, dws As Worksheet, Crit1 As String
Set sws = Sheets("RegionalAnalysis")
Set dws = Sheets("RegionalCustomersData")
Crit1 = sws.Range("B1").Value
dws.Cells.Clear
With sws.Range("C5", sws.Range("C" & sws.Rows.Count).End(xlUp))
.AutoFilter 1, Crit1
Range(.Offset(, -2), .Offset(, 6)).Copy dws.Range("A2")
.AutoFilter
End With
Application.ScreenUpdating = True
End Sub
...or, if there is at least one completely empty row directly above the dataset (i.e. Row 4), then this should work as well:
Sub FilterIt()
Application.ScreenUpdating = False
Dim sws As Worksheet, dws As Worksheet, Crit1 As String
Set sws = Sheets("RegionalAnalysis")
Set dws = Sheets("RegionalCustomersData")
Crit1 = sws.Range("B1").Value
dws.Cells.Clear
With sws.[A5].CurrentRegion
.AutoFilter 3, Crit1
.Columns("A:F").Copy dws.Range("A2")
.AutoFilter
End With
Application.ScreenUpdating = True
End Sub
Thanks for the rep!
Cheerio,
vcoolio.
Bookmarks