Bypass a function in a Macro

B

bevchapman

I am building a Macro that can run on a worksheet training matrix whether if
is filtered or not. It works beautifully as long as the file is filtered but
need to work both ways.

Here is the text I have for my macro so far

Sheets("Tech Plan").Select
ActiveSheet.Unprotect ("MPT8883900")
ActiveSheet.ShowAllData
ActiveSheet.Range("$A$10:$BO$569").AutoFilter Field:=53
ActiveSheet.Range("$A$10:$BO$569").AutoFilter Field:=53, Criteria1:="X"
ActiveSheet.Protect ("MPT8883900")

I am trying to bypass the ShowAllData line if it has already been
unfiltered. I have about 60 files to run this on and would appreciate any
help.
 
F

FSt1

hi
read up on the filter mode property in vb help. it's boolean and true if
the sheet contains a filtered list.
to bypass the showalldata line, you would need something like this....
if activesheet.filtermode = true then
activesheet.showalldata
else
do something else '?????
end if

regards
FSt1
 
D

Dave Peterson

With worksheets("SomeSheetNameHere")
'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


Or you could ignore errors, too:

on error resume next
ActiveSheet.ShowAllData 'keeps the arrows, shows all the data.
 

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