ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How can I get a macro to know when it false and run a different ma (https://www.excelbanter.com/excel-programming/395787-how-can-i-get-macro-know-when-false-run-different-ma.html)

Shawn777

How can I get a macro to know when it false and run a different ma
 
If the macro / code turns out to be an error Then run a different macro.

The code is:
ActiveSheet.ShowAllData

but if it is already showing all then the macro shuts down with an error
message.
Instead I want it to realize it doesnt work and run a different macro
instead.


joel

How can I get a macro to know when it false and run a different ma
 
Showall data fails becuase you don't have aoutfiltering on. You need to test
for auto filtering as follows:

Sub test()

With ActiveSheet
If .AutoFilterMode Then
.ShowAllData
Else
' enter your alternate code
End If
End With

End Sub


"Shawn777" wrote:

If the macro / code turns out to be an error Then run a different macro.

The code is:
ActiveSheet.ShowAllData

but if it is already showing all then the macro shuts down with an error
message.
Instead I want it to realize it doesnt work and run a different macro
instead.



All times are GMT +1. The time now is 07:48 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com