#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default marco to delete rows

I have a spreadsheet that in column 'C' there are times when the word
PENDING is in the cell instead of a date. I would like to have a macro
that looks at each of these cell in COlumn 'C' and removes the entire row if
the word PENDING in that cell.


Thanks in advance


  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,718
Default marco to delete rows

AutoFilter the word PENDING, then select all the PENDING rows, go to Edit
Delete Rows

"Johnfli" wrote:

I have a spreadsheet that in column 'C' there are times when the word
PENDING is in the cell instead of a date. I would like to have a macro
that looks at each of these cell in COlumn 'C' and removes the entire row if
the word PENDING in that cell.


Thanks in advance



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,939
Default marco to delete rows

Public Sub DeleteCities()
Call DeleteByWord("PENDING")
End Sub

Sub DeleteByWord(ByVal strWord As String)
Dim wks As Worksheet
Dim rngToSearch As Range
Dim rngFound As Range
Dim rngFoundAll As Range
Dim strFirstAddress As String

Set wks = Sheets("Sheet1") 'Change This
Set rngToSearch = wks.Columns("C")
Set rngFound = rngToSearch.Find(What:=strWord , _
Lookat:=xlWhole, _
LookIn:=xlFormulas, _
MatchCase:=False)
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


"Johnfli" wrote:

I have a spreadsheet that in column 'C' there are times when the word
PENDING is in the cell instead of a date. I would like to have a macro
that looks at each of these cell in COlumn 'C' and removes the entire row if
the word PENDING in that cell.


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
easy way to delete all rows with no text in them? george edgar New Users to Excel 2 May 13th 06 07:54 PM
delete rows Jack Sons Excel Discussion (Misc queries) 5 November 22nd 05 04:30 PM
Delete Rows where cells does not meet criteria Danny Excel Worksheet Functions 1 September 12th 05 05:08 PM
Want to delete rows Farooq Sheri Excel Discussion (Misc queries) 6 September 12th 05 12:46 PM
How can we delete rows permanently from excel sheet Nehal Shah Excel Discussion (Misc queries) 1 August 1st 05 01:58 PM


All times are GMT +1. The time now is 11:41 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"