Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Jim Thomlinson recently posted code to do this
Sub DeleteUnwanted(ByVal DeleteWord As String) Dim wks As Worksheet Dim rngToSearch As Range Dim rngCurrent As Range Dim rngDelete As Range Dim rngFirst As Range Set wks = Sheets("Sheet1") Set rngToSearch = wks.Cells Set rngCurrent = rngToSearch.Find(DeleteWord) If Not rngCurrent Is Nothing Then Set rngDelete = rngCurrent Set rngFirst = rngCurrent Do Set rngDelete = Union(rngCurrent, _ rngCurrent.Offset(1,0), rngDelete) Set rngCurrent = rngToSearch.FindNext(rngCurrent) Loop Until rngCurrent.Address = rngFirst.Address rngDelete.EntireRow.Delete End If End Sub You can find similar in the help example for findnext, but Jim had altered the basic approach to collect all the found cells and delete at once - which should be faster. For consistency, you should set all the options for the Find command. Such as Lookat:=xlPart expression.Find(What, After, LookIn, LookAt, SearchOrder, SearchDirection) -- Regards, Tom Ogilvy "childofthe1980s" wrote in message ... Hello: I have a huge spreadsheet of over 20,000 rows. I want to delete any row that has a cell that contains the phrase "Ending Balance". Is there a way to tell Excel to delete such rows, without my having to delete each of the rows one by one? If I manually delete these rows, it will take hours. Thanks! childofthe1980s |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Macro for deleting rows and serialising the remaing rows | Links and Linking in Excel | |||
Macro for deleting rows and serialising the remaing rows | Setting up and Configuration of Excel | |||
Macro for deleting rows and serialising the remaing rows | Excel Worksheet Functions | |||
Help!! I have problem deleting 2500 rows of filtered rows!!!! | Excel Discussion (Misc queries) | |||
deleting hidden rows so i can print only the rows showing?????? | Excel Worksheet Functions |