LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA to stop if autofilter macro will wipe out all data

Hello - is there a way (I'm sure there is but I'm not smart enough to figure it out) to test whether a filter vba command will result in wiping out all data?

Sub test()

'delete rows that contain the word "paper" in Column D

Worksheets("Sheet1").Range("A1").AutoFilter Field:=4, Criteria1:="<*paper*"
Application.DisplayAlerts = False
ActiveSheet.UsedRange.Offset(1, 0).Resize(ActiveSheet.UsedRange.Rows.Count - 1).Rows.Delete
Application.DisplayAlerts = True
ActiveSheet.ShowAllData

'end of "paper" check

'start next sequence ..etc
Columns("F:F").Select
etc, etc, etc

End Sub

In other words, if the data set does not have the keyword "paper" in Column D, then the above vba commands will delete all the data.

Looking for a macro that will precede the above to check whether Column D has any instances of the word "paper" *BEFORE* running the macro. If no "paper" exists in the Column, then the sequence should be bypassed and continue to the next set of vba commands immediately after (ie. jump immediately to Selecting Column F as shown above).

Thank you in advance!
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro / Autofilter / Show All Data CousinExcel Excel Discussion (Misc queries) 3 February 17th 10 01:28 PM
How can I use Text to wipe out subsequent dates? Max Excel Discussion (Misc queries) 3 April 17th 07 08:23 PM
How to stop the last record always appearing when I Autofilter TAG Excel Discussion (Misc queries) 1 July 26th 06 12:48 PM
how to stop/ restart macro after selecting from autofilter list ronnie davidson Excel Discussion (Misc queries) 2 April 6th 06 03:19 PM
Stop Macro if there is no data STEVEB Excel Programming 13 February 8th 06 09:41 PM


All times are GMT +1. The time now is 08:25 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"