Forum Discussion

anolinde's avatar
anolinde
Copper Contributor
Jan 13, 2021
Solved

VBA Error (but only on one sheet): Object variable or With block variable not set

I'm using Excel in Microsoft Office 365 on Windows 10. I've been using a macro to sort two tabs on my spreadsheet, which are identical in format, and after months of working perfectly, now the macro ...
  • HansVogelaar's avatar
    Jan 13, 2021

    anolinde 

    You'd get this error if the range doesn't have filter turned on, so that ActiveSheet.AutoFilter is undefined. Add the following lines at the beginning of the macro:

     

        If Not ActiveSheet.AutoFilterMode Then
            Range("A1").AutoFilter
        End If

Resources