Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 318
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,939
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,124
Default 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
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
How to delete cell values withour deleting cell formulae perfection Excel Discussion (Misc queries) 5 June 18th 07 09:05 PM
How to delete cell values without affecting cell formulae perfection Excel Discussion (Misc queries) 0 June 18th 07 06:55 AM
DELETE ONLY * IN A CELL deleting a character Excel Discussion (Misc queries) 2 November 4th 06 10:37 PM
Delete cell on 1 page: automatically delete on another page? mountain view Excel Worksheet Functions 0 September 28th 06 04:18 PM
Delete cell contents with input to adjacent cell Ashley Frank Excel Discussion (Misc queries) 1 October 5th 05 04:28 PM


All times are GMT +1. The time now is 05:40 AM.

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

About Us

"It's about Microsoft Excel"