Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

auto filter and macro 1

Status
Not open for further replies.

SharonMee

MIS
May 7, 2004
210
CA
Hi all:

Hope I can get your assistance on the following: Before I run my main code in excel, I would like to turn off the autofilter. My code runs a filter and then searches for a value. Then it runs another filter and then searches for a different value.

My question is: How do I write a code so that excel turns off the filter before running the main code. I tried using:

Rows("1:1").Select
Selection.AutoFilter

But it doesn't work on occasions because my code exits the sub, my code exists the sub if excel does not find the value. So, when I run another code that contains the value being searched, the code does not work properly, because the autofilter has not been turned off, the code above does not do the job.

What code would I use to turn the autofilter off before a new code is run.

thanks for helping

SharonMee
 
Something like this ?
If ActiveSheet.FilterMode Then ActiveSheet.AutoFilter

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hi PH,

I tried:

Sheet3.Select
LastRow = Cells(Rows.Count, "c").End(xlUp).Row
If (LastRow >= 6) Then
Rows("6:" & LastRow).Select
Selection.Delete Shift:=xlUp
End If
Sheet5.Select
If ActiveSheet.FilterMode Then
ActiveSheet.AutoFilter
End If

But I got a debug error: Object doesn't support this property or method and the line ActiveSheet.Autofilter is highlighted, do you know why?

Thanks

 
Sorry for the typo:
If ActiveSheet.AutoFilterMode Then ActiveSheet.AutoFilterMode = False

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top