LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Deleting rows that don't contain keywords

Tom, Friday.
However, it COULD find the valuesmove the row to the next available row on
another sheetdelete what's leftmove all the rows back. Not good but saves
a little bit of face. <G

--
Don Guillett
SalesAid Software

"Tom Ogilvy" wrote in message
...
To the OP.

I don't see where Find or FindNext has any role to play in deleting rows
that don't contain some prescribed value (except in a most roundabout
fashion).

Maybe that will save you some time.

--
Regards,
Tom Ogilvy


"Don Guillett" wrote:

As mentioned, you need to use cells(r,c) but if your strings to find are
all
in the same column then
sub deleterows()
for i =1 to cells(rows.count,"a").end(xlup).row
if cells(i,"a")="NAME:" or cells(i,"a")="SUBJ:" then rows(i).delete
next i
end sub

If not in the same column, look in the vba help index for FINDNEXT. There
is
a good example. There is no reason to look at EVERY cell.

--
Don Guillett
SalesAid Software

"Chris" wrote in message
ups.com...
I have this following macro which I want to scan through all cells in
my worksheet and delete all rows that don't contain the keywords
"NAME:" and that don't contain the keywords "SUBJ:" I keep getting an
error on "test = Application.Range(r,c).Text" It says "method Range of
object _Application failed" Does anyone know how to get the text from
each cell and compare it to the strings I have? Thanks

Sub DeleteR()
Dim bool As Boolean
For r = Application.Rows.Count To 1 Step -1
bool = False
For c = Application.Columns.Count To 1 Step -1
Dim test As String
test = Application.Range(r, c).Text
If test = "NAME:" Then
'mark bool as true (we found a table name row)
bool = True
End If
If test = "SUBJ:" Then
'mark bool as true (we found a subject area row)
bool = True
End If
Next c
If bool = False Then
'Delete entire row
Application.Rows(r).EntireRow.Delete
End If
Next r
End Sub




 
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
Macro for deleting rows and serialising the remaing rows Srinivasulu Bhattaram Links and Linking in Excel 1 November 13th 08 08:44 AM
Macro for deleting rows and serialising the remaing rows Srinivasulu Bhattaram Setting up and Configuration of Excel 1 November 12th 08 06:05 PM
Macro for deleting rows and serialising the remaing rows Srinivasulu Bhattaram Excel Worksheet Functions 1 November 12th 08 01:39 PM
Help!! I have problem deleting 2500 rows of filtered rows!!!! shirley_kee Excel Discussion (Misc queries) 1 January 12th 06 03:24 AM
Help!!! I have problem deleting 2500 rows of filtered rows shirley_kee[_2_] Excel Programming 1 January 12th 06 03:15 AM


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