Hello,
I'm trying to select multiple sheets based on their color and perform other tasks on each one. I need to make sure the autofilter mode is off on these sheets, the codes I have now don't work:
I got an error on the line "sh.autofiltermode = false". Can someone please help me to fix this?PHP Code:
Sub removeFilterRecBook()
Dim sh As Worksheet
Dim wsNames() As String
Dim wsColor() As Integer
Dim ws As Worksheet
Dim ind As Integer
Workbooks("Recs.xlsm").Activate
If ActiveWindow.SelectedSheets.Count > 1 Then
Worksheets("111100Detail").Select
Else
Worksheets("111100Detail").Select
End If
ReDim wsNames(0)
ReDim wsColor(0)
wsNames(0) = ActiveSheet.Name
wsColor(0) = ActiveSheet.Tab.ColorIndex
For Each ws In ActiveWorkbook.Sheets
If ws.Tab.ColorIndex = wsColor(0) Then
ReDim Preserve wsNames(UBound(wsNames) + 1)
ReDim Preserve wsColor(UBound(wsColor) + 1)
wsNames(UBound(wsNames)) = ws.Name
wsColor(UBound(wsColor)) = ws.Tab.ColorIndex
End If
Next ws
Sheets(wsNames).Select
For Each sh In ActiveWindow.SelectedSheets
If sh.AutoFilterMode Then
sh.AutoFilterMode = False
End If
Next sh
If ActiveWindow.SelectedSheets.Count > 1 Then
Worksheets("TB").Select
Else
Worksheets("TB").Select
End If
On Error GoTo 0
End Sub
thanks so much
Bookmarks