Autofilter turn off with macro

S

Shaggyjh

Another macro question about the autofilter!

I have a macro as below that filters my worksheet to only show rows where
there is a value in column C and outputs it to the print preview screen.
When you close the preview screen the print range is selected and the filter
is still on.

Is there anyway of editing the macro so that when you close the print
preview screen the worksheet has no selection or filter?

The Macro:

Sub setprintarea()

Range("A14:j65536").Select
Selection.AutoFilter
Selection.AutoFilter Field:=3, Criteria1:="<>"
Columns("A:j").Select
Range("A2").Activate
Selection.PrintOut Copies:=1, Preview:=True, Collate:=True

End Sub
 
G

Gary''s Student

AutoFilter toggles; so just add another:

Range("A14:j65536").Select
Selection.AutoFilter

at the end
 
S

Simon Lloyd

How about this?

Sub setprintarea()
With Range("A14:j65536")
..AutoFilter
..AutoFilter Field:=3, Criteria1:="<>"
End With
Columns("A:j").Select
Range("A2").Activate
Selection.PrintOut Copies:=1, Preview:=True, Collate:=True
Range("A1").Select
ActiveSheet.Columns.AutoFilter
End Sub


Shaggyjh;319458 said:
Another macro question about the autofilter!

I have a macro as below that filters my worksheet to only show rows
where
there is a value in column C and outputs it to the print preview
screen.
When you close the preview screen the print range is selected and the
filter
is still on.

Is there anyway of editing the macro so that when you close the print
preview screen the worksheet has no selection or filter?

The Macro:

Sub setprintarea()

Range("A14:j65536").Select
Selection.AutoFilter
Selection.AutoFilter Field:=3, Criteria1:="<>"
Columns("A:j").Select
Range("A2").Activate
Selection.PrintOut Copies:=1, Preview:=True, Collate:=True

End Sub


--
Simon Lloyd

Regards,
Simon Lloyd
'The Code Cage' (http://www.thecodecage.com)
 
D

Dave Peterson

With worksheets("Sheet9999")
'to remove the filter and the arrows
.AutoFilterMode = False

'or to just show all the data and keep the arrows
If .FilterMode Then
.ShowAllData
End If
End With
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top