Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
delete row if cell value =
Hello
I received a daily report , a large spreadsheet ,I need to delete all rows that have the words SD, MC, MO in column D Thanks in advance I know how to create a simple delete row Sub DeleteRows() Rows("3:" & Rows.Count).Delete End Sub I've been using a filter - but a VBA code will be faster thanks in advance |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
delete row if cell value =
This would be my take...
Public Sub MainDelete() Call DeleteStuff("SD") Call DeleteStuff("MC") Call DeleteStuff("MO") End Sub Public Sub DeleteStuff(ByVal strToDelete As String) Dim rngFound As Range Dim rngFoundAll As Range Dim strFirstAddress As String Dim rngToSearch As Range Set rngToSearch = Columns("D") Set rngFound = rngToSearch.Find(What:=strToDelete, _ LookAt:=xlWhole, _ LookIn:=xlFormulas, _ MatchCase:=True) If Not rngFound Is Nothing Then Set rngFoundAll = rngFound strFirstAddress = rngFound.Address Do Set rngFoundAll = Union(rngFound, rngFoundAll) Set rngFound = rngToSearch.FindNext(rngFound) Loop Until rngFound.Address = strFirstAddress rngFoundAll.EntireRow.Delete End If End Sub -- HTH... Jim Thomlinson "Wanna Learn" wrote: Hello I received a daily report , a large spreadsheet ,I need to delete all rows that have the words SD, MC, MO in column D Thanks in advance I know how to create a simple delete row Sub DeleteRows() Rows("3:" & Rows.Count).Delete End Sub I've been using a filter - but a VBA code will be faster thanks in advance |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
delete row if cell value =
Use a loop from the BOTTOM up to delete each row if or record a macro while filtering on each and deleting. depending on the number of rows as to the quickest. -- Don Guillett Microsoft MVP Excel SalesAid Software "Wanna Learn" wrote in message ... Hello I received a daily report , a large spreadsheet ,I need to delete all rows that have the words SD, MC, MO in column D Thanks in advance I know how to create a simple delete row Sub DeleteRows() Rows("3:" & Rows.Count).Delete End Sub I've been using a filter - but a VBA code will be faster thanks in advance |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How to delete cell values withour deleting cell formulae | Excel Discussion (Misc queries) | |||
How to delete cell values without affecting cell formulae | Excel Discussion (Misc queries) | |||
DELETE ONLY * IN A CELL | Excel Discussion (Misc queries) | |||
Delete cell on 1 page: automatically delete on another page? | Excel Worksheet Functions | |||
Delete cell contents with input to adjacent cell | Excel Discussion (Misc queries) |