The AutoFilter object is used in two contexts. In the context of a worksheet and in the context of a Table. We use the first way when we are NOT using a Table (ListObject). In that case, there can be only one data range for Autofilter. The second way, of course, applies to Tables.
The event code shown refers to Autofilter in the context of a sheet, and since you have Tables, you get an error.
If there was only one Table in the sheet, you could check if the cell being changed belongs to that Table like this:
Since you have several Tables, you first need to check which Table the cell being changed belongs to. And only then perform the action on the specified Table.
Try using the following code
If you change a cell outside of any of the tables, the table in the For Each...Next loop will not be found and the LO variable will contain Nothing. So the condition
will not be executed.
You can use the presented code construction when you have many tables in the sheet, but also for a single table.
Artik
Bookmarks