PC Review


Reply
Thread Tools Rate Thread

detect the filter mode ?

 
 
Jamen Lone
Guest
Posts: n/a
 
      12th Jul 2009
Hi all,

I need a function to see if the autofilter is defined (so activ) and the
rows are selected

I tried it by this

Function FilterOn()
If ActiveSheet.FilterMode = True Then
... here should be "TRUE"
Else
..... here should be "FALSE"
End If
End Function


Can someone help me ?
--

Jamen


 
Reply With Quote
 
 
 
 
Peter T
Guest
Posts: n/a
 
      12th Jul 2009
Sub test()
MsgBox TickedFilters(ActiveSheet)
End Sub

Function TickedFilters(ws As Worksheet) As Long
Dim cntOn As Long
Dim af As AutoFilter, f As Filter

If Not ws.AutoFilter Is Nothing Then
If ws.FilterMode Then
Set af = ws.AutoFilter
For Each f In af.Filters
If f.On Then cntOn = cntOn + 1
Next
End If
End If
TickedFilters = cntOn

End Function

As written the function doesn't prove any rows are hidden, if you need that
look for hidden rows in ws.AutoFilter.Range

Regards,
Peter T

"Jamen Lone" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Hi all,
>
> I need a function to see if the autofilter is defined (so activ) and the
> rows are selected
>
> I tried it by this
>
> Function FilterOn()
> If ActiveSheet.FilterMode = True Then
> .. here should be "TRUE"
> Else
> .... here should be "FALSE"
> End If
> End Function
>
>
> Can someone help me ?
> --
>
> Jamen
>



 
Reply With Quote
 
Jamen Lone
Guest
Posts: n/a
 
      12th Jul 2009
How should I use this function in a sheet ?

I tried =TickedFilters() in cell A1, but it doesn't work.
sorry, but I'm firm in vba.

Jamen

"Peter T" <peter_t@discussions> schrieb im Newsbeitrag
news:(E-Mail Removed)...
> Sub test()
> MsgBox TickedFilters(ActiveSheet)
> End Sub
>
> Function TickedFilters(ws As Worksheet) As Long
> Dim cntOn As Long
> Dim af As AutoFilter, f As Filter
>
> If Not ws.AutoFilter Is Nothing Then
> If ws.FilterMode Then
> Set af = ws.AutoFilter
> For Each f In af.Filters
> If f.On Then cntOn = cntOn + 1
> Next
> End If
> End If
> TickedFilters = cntOn
>
> End Function
>
> As written the function doesn't prove any rows are hidden, if you need
> that look for hidden rows in ws.AutoFilter.Range
>
> Regards,
> Peter T
>
> "Jamen Lone" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>> Hi all,
>>
>> I need a function to see if the autofilter is defined (so activ) and the
>> rows are selected
>>
>> I tried it by this
>>
>> Function FilterOn()
>> If ActiveSheet.FilterMode = True Then
>> .. here should be "TRUE"
>> Else
>> .... here should be "FALSE"
>> End If
>> End Function
>>
>>
>> Can someone help me ?
>> --
>>
>> Jamen
>>

>
>



 
Reply With Quote
 
Jamen Lone
Guest
Posts: n/a
 
      12th Jul 2009
I'm not firm :-)

"Jamen Lone" <(E-Mail Removed)> schrieb im Newsbeitrag
news:%(E-Mail Removed)...
> How should I use this function in a sheet ?
>
> I tried =TickedFilters() in cell A1, but it doesn't work.
> sorry, but I'm firm in vba.
>
> Jamen
>
> "Peter T" <peter_t@discussions> schrieb im Newsbeitrag
> news:(E-Mail Removed)...
>> Sub test()
>> MsgBox TickedFilters(ActiveSheet)
>> End Sub
>>
>> Function TickedFilters(ws As Worksheet) As Long
>> Dim cntOn As Long
>> Dim af As AutoFilter, f As Filter
>>
>> If Not ws.AutoFilter Is Nothing Then
>> If ws.FilterMode Then
>> Set af = ws.AutoFilter
>> For Each f In af.Filters
>> If f.On Then cntOn = cntOn + 1
>> Next
>> End If
>> End If
>> TickedFilters = cntOn
>>
>> End Function
>>
>> As written the function doesn't prove any rows are hidden, if you need
>> that look for hidden rows in ws.AutoFilter.Range
>>
>> Regards,
>> Peter T
>>
>> "Jamen Lone" <(E-Mail Removed)> wrote in message
>> news:%(E-Mail Removed)...
>>> Hi all,
>>>
>>> I need a function to see if the autofilter is defined (so activ) and the
>>> rows are selected
>>>
>>> I tried it by this
>>>
>>> Function FilterOn()
>>> If ActiveSheet.FilterMode = True Then
>>> .. here should be "TRUE"
>>> Else
>>> .... here should be "FALSE"
>>> End If
>>> End Function
>>>
>>>
>>> Can someone help me ?
>>> --
>>>
>>> Jamen
>>>

>>
>>

>
>



 
Reply With Quote
 
Peter T
Guest
Posts: n/a
 
      12th Jul 2009
You mean you want to use it as a UDF, try this

Function TickedFilters(cell As Range) As Variant
Dim ws As Worksheet
Dim cntOn As Long
Dim af As AutoFilter, f As Filter

On Error GoTo errH
Set ws = cell.Parent
If Not ws.AutoFilter Is Nothing Then
If ws.FilterMode Then
Set af = ws.AutoFilter
For Each f In af.Filters
If f.On Then cntOn = cntOn + 1
Next
End If
End If
TickedFilters = cntOn
Exit Function
errH:
TickedFilters = Err.Description

End Function


in a cell
=TickedFilters(A1)+NOW()*0

the cell ref can be any cell on the sheet, probably better to make it the
same cell as the formula cell. the NOW stuff is to help it update if user
changes a filter setting.

Regards,
Peter T



"Jamen Lone" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> How should I use this function in a sheet ?
>
> I tried =TickedFilters() in cell A1, but it doesn't work.
> sorry, but I'm firm in vba.
>
> Jamen
>
> "Peter T" <peter_t@discussions> schrieb im Newsbeitrag
> news:(E-Mail Removed)...
>> Sub test()
>> MsgBox TickedFilters(ActiveSheet)
>> End Sub
>>
>> Function TickedFilters(ws As Worksheet) As Long
>> Dim cntOn As Long
>> Dim af As AutoFilter, f As Filter
>>
>> If Not ws.AutoFilter Is Nothing Then
>> If ws.FilterMode Then
>> Set af = ws.AutoFilter
>> For Each f In af.Filters
>> If f.On Then cntOn = cntOn + 1
>> Next
>> End If
>> End If
>> TickedFilters = cntOn
>>
>> End Function
>>
>> As written the function doesn't prove any rows are hidden, if you need
>> that look for hidden rows in ws.AutoFilter.Range
>>
>> Regards,
>> Peter T
>>
>> "Jamen Lone" <(E-Mail Removed)> wrote in message
>> news:%(E-Mail Removed)...
>>> Hi all,
>>>
>>> I need a function to see if the autofilter is defined (so activ) and the
>>> rows are selected
>>>
>>> I tried it by this
>>>
>>> Function FilterOn()
>>> If ActiveSheet.FilterMode = True Then
>>> .. here should be "TRUE"
>>> Else
>>> .... here should be "FALSE"
>>> End If
>>> End Function
>>>
>>>
>>> Can someone help me ?
>>> --
>>>
>>> Jamen
>>>

>>
>>

>
>



 
Reply With Quote
 
Jamen Lone
Guest
Posts: n/a
 
      12th Jul 2009
thanks .. that's exactly the thing I'm looking for :-)
you're great

"Peter T" <peter_t@discussions> schrieb im Newsbeitrag
news:(E-Mail Removed)...
> You mean you want to use it as a UDF, try this
>
> Function TickedFilters(cell As Range) As Variant
> Dim ws As Worksheet
> Dim cntOn As Long
> Dim af As AutoFilter, f As Filter
>
> On Error GoTo errH
> Set ws = cell.Parent
> If Not ws.AutoFilter Is Nothing Then
> If ws.FilterMode Then
> Set af = ws.AutoFilter
> For Each f In af.Filters
> If f.On Then cntOn = cntOn + 1
> Next
> End If
> End If
> TickedFilters = cntOn
> Exit Function
> errH:
> TickedFilters = Err.Description
>
> End Function
>
>
> in a cell
> =TickedFilters(A1)+NOW()*0
>
> the cell ref can be any cell on the sheet, probably better to make it the
> same cell as the formula cell. the NOW stuff is to help it update if user
> changes a filter setting.
>
> Regards,
> Peter T
>
>
>
> "Jamen Lone" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>> How should I use this function in a sheet ?
>>
>> I tried =TickedFilters() in cell A1, but it doesn't work.
>> sorry, but I'm firm in vba.
>>
>> Jamen
>>
>> "Peter T" <peter_t@discussions> schrieb im Newsbeitrag
>> news:(E-Mail Removed)...
>>> Sub test()
>>> MsgBox TickedFilters(ActiveSheet)
>>> End Sub
>>>
>>> Function TickedFilters(ws As Worksheet) As Long
>>> Dim cntOn As Long
>>> Dim af As AutoFilter, f As Filter
>>>
>>> If Not ws.AutoFilter Is Nothing Then
>>> If ws.FilterMode Then
>>> Set af = ws.AutoFilter
>>> For Each f In af.Filters
>>> If f.On Then cntOn = cntOn + 1
>>> Next
>>> End If
>>> End If
>>> TickedFilters = cntOn
>>>
>>> End Function
>>>
>>> As written the function doesn't prove any rows are hidden, if you need
>>> that look for hidden rows in ws.AutoFilter.Range
>>>
>>> Regards,
>>> Peter T
>>>
>>> "Jamen Lone" <(E-Mail Removed)> wrote in message
>>> news:%(E-Mail Removed)...
>>>> Hi all,
>>>>
>>>> I need a function to see if the autofilter is defined (so activ) and
>>>> the rows are selected
>>>>
>>>> I tried it by this
>>>>
>>>> Function FilterOn()
>>>> If ActiveSheet.FilterMode = True Then
>>>> .. here should be "TRUE"
>>>> Else
>>>> .... here should be "FALSE"
>>>> End If
>>>> End Function
>>>>
>>>>
>>>> Can someone help me ?
>>>> --
>>>>
>>>> Jamen
>>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Detect system goto sleep mode, hibernation mode, switch user, logo =?Utf-8?B?c3RldmU=?= Microsoft C# .NET 3 7th Oct 2005 07:23 PM
How to detect IMO/CW mode in outlook2000 Ashutosh Choubey Microsoft Outlook Form Programming 0 3rd Aug 2005 07:14 AM
No match on Advanced Filter -- how to detect? Dianne Microsoft Excel Programming 1 5th Nov 2003 07:45 PM
Detect Group mode Tim Aurthur Microsoft Excel Programming 3 22nd Oct 2003 06:17 PM
How to detect Offline mode? Martynas Kunigelis Microsoft Outlook Program Addins 4 8th Aug 2003 10:39 PM


Features
 

Advertising
 

Newsgroups
 


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