ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How? - Error message for turning off autofilter with code (https://www.excelbanter.com/excel-programming/302938-how-error-message-turning-off-autofilter-code.html)

ryssa[_4_]

How? - Error message for turning off autofilter with code
 
I have a button on a worksheet to 'Show All Records'.

There are two ways i found to do it, ie:

ActiveSheet.ShowAllData

and

If ActiveSheet.AutoFilterMode Then
ActiveSheet.AutoFilterMode = False
End If

How do I display a message box saying "All records shown" if the use
clicks the button when the records are not filtered?

I found that the second way erases the filter arrows. I would like th
filter arrows at the top to remain.

Would appreciate anyones help, thanks

--
Message posted from http://www.ExcelForum.com


BrianB

How? - Error message for turning off autofilter with code
 
This is one of those macros that I have been meaning to get round to an
not found the necessary motivation. It now resides in my personal.xls.

To check if a filter has been set beforehand it would be necessary t
run the same loop, so there is no point. This will work in any case :-


Code
-------------------

'------------------------------------------------
Sub AUTOFILTER_RESET()
Dim MyFilter As Range
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Set MyFilter = ActiveSheet.AutoFilter.Range
cols = MyFilter.Columns.Count
'-----------------------------------
For c = 1 To cols
MyFilter.AutoFilter field:=c
Next
'-----------------------------------
Application.ScreenUpdating = True
MsgBox ("All data visible.")
Application.Calculation = xlCalculationAutomatic
End Sub
'-------------------------------------------------

-------------------


--
Message posted from http://www.ExcelForum.com


ryssa[_9_]

How? - Error message for turning off autofilter with code
 
This works for me.

Thank you very much!

ryss

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 03:01 AM.

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