I need an Excel macro that would apply the Clear function ("Clear the filter and sort…
- User
I need an Excel macro that would apply the Clear function ("Clear the filter and sort state for the current range of data") to all sheets in an active workbook.
Assistant
Here's an Excel VBA macro that will clear all filters and sorts from all worksheets in the active workbook. This is equivalent to clicking the "Clear" button in the Sort & Filter group on the ribbon, which removes both filtering and sorting applied to the data.
✅ Macro: Clear Filters and Sorts from All Sheets
Sub ClearAllFiltersAndSorts() Dim ws As Worksheet On Error Resume Next ' In case no filter/sort exists For Each ws In ActiveWorkbook.Worksheets ws.ShowAllData Next ws On Error GoTo 0 ' Turn error handling back off End Sub
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.