PC Review


Reply
Thread Tools Rate Thread

change filter with criteria back to All

 
 
=?Utf-8?B?RGVubmlz?=
Guest
Posts: n/a
 
      8th Nov 2006
I'm looping through workbooks that have filtered data. I'm using
GetObject(workbook name) because I don't want to use any select or activate
methods. I have two criteria set in each workbook. I want to turn off the
criteria on the Include/Exclude field. I'm having trouble changing this
field back to all. So I turned off the autofilter and turned it back on with
the same criteria in the Primary PMO field. However, I'm not getting it to
work.

With FS
.NewSearch
.LookIn = strDir
intCnt = .Execute
For Each varFN In .FoundFiles
Set wkbPMO = GetObject(varFN)
Set wks = wkbPMO.Sheets("Scoring Sheet")
With wks.Rows(1)
Set rFind = .Find("Include / Exclude")
intIncldCol = rFind.Column
Set rFind = .Find("Primary PMO")
intPMOCol = rFind.Column
End With
'========================================
'get value for PMO. turn off autofilter,
'then turn back on and reset the criteria
'for Primary PMO
'========================================
With wks
Set flt = .AutoFilter.Filters(intPMOCol)
strPMO = flt.Criteria1
.AutoFilterMode = False
.Range("A2").AutoFilter field:=intPMOCol, Criteria1:=strPMO
End With
wkbPMO.Close
Set wkbPMO = Nothing
Next
End With
 
Reply With Quote
 
 
 
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      8th Nov 2006
Why not turn on the macro recorder and set set the filter to all manually.

Turn off the macro recorder and look at the code to see how to set your
filter to All.

--
Regards,
Tom Ogilvy


"Dennis" wrote:

> I'm looping through workbooks that have filtered data. I'm using
> GetObject(workbook name) because I don't want to use any select or activate
> methods. I have two criteria set in each workbook. I want to turn off the
> criteria on the Include/Exclude field. I'm having trouble changing this
> field back to all. So I turned off the autofilter and turned it back on with
> the same criteria in the Primary PMO field. However, I'm not getting it to
> work.
>
> With FS
> .NewSearch
> .LookIn = strDir
> intCnt = .Execute
> For Each varFN In .FoundFiles
> Set wkbPMO = GetObject(varFN)
> Set wks = wkbPMO.Sheets("Scoring Sheet")
> With wks.Rows(1)
> Set rFind = .Find("Include / Exclude")
> intIncldCol = rFind.Column
> Set rFind = .Find("Primary PMO")
> intPMOCol = rFind.Column
> End With
> '========================================
> 'get value for PMO. turn off autofilter,
> 'then turn back on and reset the criteria
> 'for Primary PMO
> '========================================
> With wks
> Set flt = .AutoFilter.Filters(intPMOCol)
> strPMO = flt.Criteria1
> .AutoFilterMode = False
> .Range("A2").AutoFilter field:=intPMOCol, Criteria1:=strPMO
> End With
> wkbPMO.Close
> Set wkbPMO = Nothing
> Next
> End With

 
Reply With Quote
 
=?Utf-8?B?RGVubmlz?=
Guest
Posts: n/a
 
      8th Nov 2006
Tom,

I'm using GetObject() to work with the file via code. The Select and
Selections methods do not work. The macro recorder uses the the Selection
method such as:
Selection.AutoFilter Field:=30

This changes the Criteria1 value back to All. I've tried everything I can
think of. The only thing that works is turning off the autofilter, set the
the other criteria that I wanted back. However, users may use other criteria
that I may not know. So I have to loop through the other filters, set the
criteria in an array and reset then back. This is so much work, when all I
need to do is set one criteria to All.

"Tom Ogilvy" wrote:

> Why not turn on the macro recorder and set set the filter to all manually.
>
> Turn off the macro recorder and look at the code to see how to set your
> filter to All.
>
> --
> Regards,
> Tom Ogilvy
>
>
> "Dennis" wrote:
>
> > I'm looping through workbooks that have filtered data. I'm using
> > GetObject(workbook name) because I don't want to use any select or activate
> > methods. I have two criteria set in each workbook. I want to turn off the
> > criteria on the Include/Exclude field. I'm having trouble changing this
> > field back to all. So I turned off the autofilter and turned it back on with
> > the same criteria in the Primary PMO field. However, I'm not getting it to
> > work.
> >
> > With FS
> > .NewSearch
> > .LookIn = strDir
> > intCnt = .Execute
> > For Each varFN In .FoundFiles
> > Set wkbPMO = GetObject(varFN)
> > Set wks = wkbPMO.Sheets("Scoring Sheet")
> > With wks.Rows(1)
> > Set rFind = .Find("Include / Exclude")
> > intIncldCol = rFind.Column
> > Set rFind = .Find("Primary PMO")
> > intPMOCol = rFind.Column
> > End With
> > '========================================
> > 'get value for PMO. turn off autofilter,
> > 'then turn back on and reset the criteria
> > 'for Primary PMO
> > '========================================
> > With wks
> > Set flt = .AutoFilter.Filters(intPMOCol)
> > strPMO = flt.Criteria1
> > .AutoFilterMode = False
> > .Range("A2").AutoFilter field:=intPMOCol, Criteria1:=strPMO
> > End With
> > wkbPMO.Close
> > Set wkbPMO = Nothing
> > Next
> > End With

 
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
filter criteria shiro Microsoft Excel Programming 4 1st Jul 2008 09:02 PM
Adp form looses filter when filter criteria are updated Bonno Hylkema Microsoft Access ADP SQL Server 4 19th Jun 2006 10:07 AM
Re: Removing Filter Criteria from the Form's Filter Property Douglas J. Steele Microsoft Access Form Coding 3 15th Mar 2004 03:16 PM
Two different Filter criteria Microsoft Access Form Coding 0 22nd Jan 2004 03:29 PM
HELP! Change color of a control if criteria meets criteria in an unbound box Aileen Microsoft Access Forms 1 26th Sep 2003 07:49 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:29 PM.