![]() |
Autofiltering macro does not work correctly
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! |
Autofiltering macro does not work correctly
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! |
Autofiltering macro does not work correctly
Looks like you need to add this:
Range("AC9").Select right after your first PrintOut. -- Dan |
All times are GMT +1. The time now is 05:13 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com