jeudi 13 juillet 2017

If Function - If nothing, don't do anything

I have the following code to get rid of all filters applied on the worksheet without removing the filter function.

If ActiveSheet.AutoFilterMode Then ActiveSheet.ShowAllData

This works perfectly if there is a filter applied, however on occasion there will be no filter applied and I will have to run this and it errors. The error code is 1004 and is - 'ShowAllData method of worksheet class failed'.

How can i make it so this doesn't happen so if there isn't a filter, it doesn't error.

Thanks

Aucun commentaire:

Enregistrer un commentaire