Microsoft Excel - Stop Macro if Document is not filtered

Asked By Jason on 05-Apr-11 02:27 PM
Earn up to 10 extra points for answering this tough question.
Real simple question.  What would be the correct vba code to have a macro stop or display a message box if the document is not filtered.  I don't mean just have the filter on but actually filtered by some value or constraint. 


Thanks,

Jason
Jackpot . replied to Jason on 05-Apr-11 09:37 PM
Hi Jason

Try the below

Sub Macro()
  
  
If Not ActiveSheet.AutoFilter.FilterMode Then
MsgBox "Active sheet not filtered"
Exit Sub
End If
  
'Rest of your code
  
End Sub

Jason replied to Jackpot . on 06-Apr-11 09:13 AM
Yes thats exactly what I have been looking for.  Thank you