Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-11-2014, 06:48 AM
damaniam damaniam is offline Find and Delete Rows Windows 7 64bit Find and Delete Rows Office 2013
Novice
Find and Delete Rows
 
Join Date: Nov 2013
Posts: 18
damaniam is on a distinguished road
Default Find and Delete Rows

Looking for a macro to delete rows where Column A contains a certain value. I've attached a copy of the worksheet (sanitized to remove any personal info). This will be typical application. The goal here is to delete all row based upon the following information, if a row is found to contain that information in column A otherwise move on down the list. While the number list could possibly contain up to 4k lines, in any given scenario only about 300 lines will be used at most.


5000-5999 Delete
6000-6899 Keep
7000-7499 Keep
7500-8299 Delete
8400-9599 Delete
8300-8399 Keep
9600-9699 Keep
9700-9999 Delete

The following macro is one that I have used in the past for a similar idea but not sure how to alter it to run for so many possible numbers.

Code:
Sub DeleteExcess()


'THIS DELETES ALL ROWS WHERE THE VALUE IN COLUMN A IS "P"
    Dim FoundCell As Range
    Application.ScreenUpdating = False
    Set FoundCell = Range("A4:A220").Find(what:="p")
    Do Until FoundCell Is Nothing
        FoundCell.EntireRow.Delete
        Set FoundCell = Range("A4:A220").FindNext
    Loop
End Sub
Thanks in advance for the help.


Cross posted at http://www.excelforum.com/excel-prog...ml#post3616238
Attached Files
File Type: xlsx Sanitary Worksheet.xlsx (16.5 KB, 7 views)
Reply With Quote
  #2  
Old 03-11-2014, 06:54 AM
damaniam damaniam is offline Find and Delete Rows Windows 7 64bit Find and Delete Rows Office 2013
Novice
Find and Delete Rows
 
Join Date: Nov 2013
Posts: 18
damaniam is on a distinguished road
Default

posted under word vba and not excel vba incorrectly if a move or a delete is possible by an admin I'd gladly repost correctly. Apologies in advance.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find and Delete Rows Macro to delete all empty rows from all tables braddgood Word VBA 15 10-02-2015 01:54 PM
Find and Delete Rows Word Macro to find and delete rows that contain adjacent cells containing "." AlexanderJohnWilley Word VBA 7 11-08-2012 10:15 AM
Find and Delete Rows Delete all rows but the last. elky1967 Word VBA 14 09-21-2012 05:27 AM
Find and Delete Rows Macro to conditionally delete rows Steve_D Excel 2 08-24-2012 09:37 PM
Find and Delete Rows Macro to delete rows with all empty cells ubns Excel Programming 2 08-14-2012 02:01 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:19 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft