ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   autofilter's events (https://www.excelbanter.com/excel-programming/276719-autofilters-events.html)

Mark[_17_]

autofilter's events
 
Hi,
I look up in VBA easy syntax for solution of below problem.
I'd like to get some info (e.g. info about amount of
selected records) after make a choice in autofilter.
It should be work only if filter is selected.

I would be very grateful for any help and all suggestions.
Regards
Mark

Harald Staff[_5_]

autofilter's events
 
Hi Mark

Sub test()
If ActiveSheet.AutoFilterMode Then
MsgBox Application.WorksheetFunction.Subtotal(2, Range("A2:A1000"))
Else
MsgBox "No filter"
End If
End Sub

or simply a worksheet formula in a cell:
=SUBTOTAL(2,A2:A1000)

--
HTH. Best wishes Harald
Excel MVP
Followup to newsgroup only please

"Mark" skrev i melding
...
Hi,
I look up in VBA easy syntax for solution of below problem.
I'd like to get some info (e.g. info about amount of
selected records) after make a choice in autofilter.
It should be work only if filter is selected.

I would be very grateful for any help and all suggestions.
Regards
Mark




Harald Staff[_5_]

autofilter's events
 
If you insert my SUBTOTAL formula into a cell then autofiltering will trig
the worksheets CALCULATE event, otherwise it won't. Think that's your only
option, but I may of course be wrong.

--
HTH. Best wishes Harald
Excel MVP
Followup to newsgroup only please

"Mark" skrev i melding
...
Harald,
I meant about uniwersal code and event, which to do
automatically after choice. Without any button.
Thx




Mark[_17_]

autofilter's events
 
I don't find any events associate with change filter,
either..
So, remain me use subtotal.
Best regards for helper.
Mark

-----Original Message-----
To the best of my knowledge:
There aren't any events triggered by filter activities

beyond the general
calculate event if there are cell dependencies.

there is no change event, or Click event associated with

selecting criteria
in the dropdown.

Anything you do with respect to this will have to be

based on your own
"cleverness".

--
Regards,
Tom Ogilvy



"Mark" wrote in message
...
I'd like only find development code (below) about events
when I choise in filter.
As you see with calculation I managed.


Sub examp()
Dim rng As Range
Set rng = ActiveSheet.AutoFilter.Range

MsgBox rng.Columns(1). _
SpecialCells(xlVisible).Count - 1 _
& " of " & Range("A1").CurrentRegion.Rows.Count - 1

& "
Records"

End Sub


-----Original Message-----
If you insert my SUBTOTAL formula into a cell then

autofiltering will trig
the worksheets CALCULATE event, otherwise it won't.

Think
that's your only
option, but I may of course be wrong.

--
HTH. Best wishes Harald
Excel MVP
Followup to newsgroup only please

"Mark" skrev i melding
...
Harald,
I meant about uniwersal code and event, which to do
automatically after choice. Without any button.
Thx


.



.



All times are GMT +1. The time now is 01:25 PM.

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