PC Review


Reply
Thread Tools Rate Thread

Autofiltering macro does not work correctly

 
 
=?Utf-8?B?ZmVybWVybG8=?=
Guest
Posts: n/a
 
      9th Aug 2007
Hi!

I would like to know if somebody can help me, i have some macros with
autofilter that doesn´t work correclty. When i run them, the first filter
works well but the second time it seems like there aren't anything.

If i do it manually there are the information i asking for but when i run
the macro it doesn't filter.

In fact, when i ask for all columns by the mecro code it only shows the
titles with no information. But if i do it manually it works ok.

I´m putting the code but i´m almost sure it is ok because some weeks before
it did it well and i didn´t change it.

I tried doing that file again and reccording a new macro but when i was
recording it it ran perfectly well but when i ran the macro it did it again.

Please hel me, i´m desesperate.

This is the code.

Columns("B:E").Select
Selection.EntireColumn.Hidden = True
Range("A6:O430").Select
ActiveSheet.PageSetup.PrintArea = "$A$6:$O$430"
Range("AE8").Select
ActiveCell.FormulaR1C1 = "2"
Range("AE9").Select
Selection.AutoFilter Field:=31, Criteria1:="CONF" ((IT WORKS))
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Selection.AutoFilter Field:=29, Criteria1:="CETES" (((IT DOESN´T FILTER)))
Range("J6:O7").Select
ActiveWindow.SelecteSheets.PrintOut Copies:=1, Collate:=True
Range("AE8").Select
ActiveCell.FormulaR1C1 = "17"
Range("AE9").Select
Selection.AutoFilter Field:=31, Criteria1:="CONF" (((IT DOESN´T FILTER)))
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Range("AC9").Select
Selection.AutoFilter Field:=29 (((IT DOESN´T FILTER)))
Range("AE8").Select
ActiveCell.FormulaR1C1 = "10"
Range("AE9").Select
Selection.AutoFilter Field:=31, Criteria1:="CONF" (((IT DOESN´T FILTER)))
Range("J8").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Range("AE9").Select
Selection.AutoFilter Field:=31 (((IT DOESN´T FILTER ANYTHING)))


THANK U VERY MUCH!
 
Reply With Quote
 
 
 
 
=?Utf-8?B?SmltIEphY2tzb24=?=
Guest
Posts: n/a
 
      9th Aug 2007
Try placing "Selection.Autofilter" just before each autofilter command.
--
Best wishes,

Jim


"fermerlo" wrote:

> Hi!
>
> I would like to know if somebody can help me, i have some macros with
> autofilter that doesn´t work correclty. When i run them, the first filter
> works well but the second time it seems like there aren't anything.
>
> If i do it manually there are the information i asking for but when i run
> the macro it doesn't filter.
>
> In fact, when i ask for all columns by the mecro code it only shows the
> titles with no information. But if i do it manually it works ok.
>
> I´m putting the code but i´m almost sure it is ok because some weeks before
> it did it well and i didn´t change it.
>
> I tried doing that file again and reccording a new macro but when i was
> recording it it ran perfectly well but when i ran the macro it did it again.
>
> Please hel me, i´m desesperate.
>
> This is the code.
>
> Columns("B:E").Select
> Selection.EntireColumn.Hidden = True
> Range("A6:O430").Select
> ActiveSheet.PageSetup.PrintArea = "$A$6:$O$430"
> Range("AE8").Select
> ActiveCell.FormulaR1C1 = "2"
> Range("AE9").Select
> Selection.AutoFilter Field:=31, Criteria1:="CONF" ((IT WORKS))
> ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
> Selection.AutoFilter Field:=29, Criteria1:="CETES" (((IT DOESN´T FILTER)))
> Range("J6:O7").Select
> ActiveWindow.SelecteSheets.PrintOut Copies:=1, Collate:=True
> Range("AE8").Select
> ActiveCell.FormulaR1C1 = "17"
> Range("AE9").Select
> Selection.AutoFilter Field:=31, Criteria1:="CONF" (((IT DOESN´T FILTER)))
> ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
> Range("AC9").Select
> Selection.AutoFilter Field:=29 (((IT DOESN´T FILTER)))
> Range("AE8").Select
> ActiveCell.FormulaR1C1 = "10"
> Range("AE9").Select
> Selection.AutoFilter Field:=31, Criteria1:="CONF" (((IT DOESN´T FILTER)))
> Range("J8").Select
> ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
> Range("AE9").Select
> Selection.AutoFilter Field:=31 (((IT DOESN´T FILTER ANYTHING)))
>
>
> THANK U VERY MUCH!

 
Reply With Quote
 
Dan R.
Guest
Posts: n/a
 
      9th Aug 2007
Looks like you need to add this:

Range("AC9").Select

right after your first PrintOut.

--
Dan

 
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
Macro for Autofiltering certain dates Simon Microsoft Excel Programming 1 11th Jan 2010 04:47 PM
Excel 2003 macro for turning on AtoZ autofiltering on a protected statum Microsoft Excel Programming 5 15th Jun 2009 03:51 AM
Autofilter / Sort MACRO doesn't work correctly Richard Microsoft Excel Programming 0 9th Feb 2009 11:33 PM
Does Custom Autofiltering dates work in XML Lists? jim_0068 Microsoft Excel Discussion 3 30th May 2006 04:08 PM
Reg autofiltering using macro in excel with out providing criteria =?Utf-8?B?SnVubw==?= Microsoft Excel Worksheet Functions 3 26th May 2006 12:21 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:47 AM.