![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Apr 2002
Posts: 113
|
SOLVED, THANKS. I was looking for a command related to "autofilter", but "filter" does what I needed.
PS. In XL97 There is code that allows use of the autofilter! I always thought that this was impossible. Sub filter() 'Protects Sheet Contents while still allowing active autofilter! ActiveSheet.EnableAutoFilter = True ActiveSheet.Protect contents:=True, userInterfaceOnly:=True End Sub ================================== I have a sheet with an autofilter. I need to turn off the autofilter while a macro runs but then I want to return it to the original condition. How can I record the autofilter criteria? I found a method to set them, but how do I get the information out? [ This Message was edited by: Brian on 2002-05-24 09:33 ] |
|
|
|
|
|
#2 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
|
Quote:
Via code or user manually sets this? Anyway here is a function that determines the criteria.....code from Steven Bullen, you will have to amend to suit your situation.... If you need to custmize this then repost with your criteria and cuurent set up. Someone is bound to help out Function FilterCriteria(Rng As Range) As String 'By Stephen Bullen Dim Filter As String Filter = "" On Error GoTo Finish With Rng.Parent.AutoFilter If Intersect(Rng, .Range) Is Nothing Then GoTo Finish With .Filters(Rng.Column - .Range.Column + 1) If Not .On Then GoTo Finish Filter = .Criteria1 Select Case .Operator Case xlAnd Filter = Filter & " AND " & .Criteria2 Case xlOr Filter = Filter & " OR " & .Criteria2 End Select End With End With Finish: FilterCriteria = Filter End Function |
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|