Hi All,
I have pieced together the below code to autofilter a workbook based on the cell entry in Sheet 1, A1. The code works great whilst sorting the information, but has a run time error when entry is " ", this entry should unsort all infomation in the previously sorted sheets.
I would also like the first two sheets excluded from the sort and the code to run on the cell change.
Sub DoFilters()
Dim w As Worksheet, RLetter As String
Dim Crit As String
Crit = Sheets("Sheet1").Range("A1").Value
RLetter = Crit
For Each w In Worksheets
If RLetter = "" Then w.Cells.AutoFilter
w.Range("A:A").AutoFilter.false
If w.FilterMode Then w.Cells.AutoFilter
w.Range("A:A").AutoFilter Field:=1, Criteria1:=Crit
Next
End Sub
Any help is much appreciated
Cheers
Adam
Bookmarks