Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Deleting Rows that Match/Contain Search Criteria

I import data for an external source into Excel. I sort and format the data
programatically.

This data contains some information that I need to delete. Searching that
range by using the following:

Columns("A:A").Find(What:="74RM",... ).Activate

How do I delete the entire row when the search criteria is found? I'm also
having difficulty understanding how to trap the error that occurs when the
search critieria is not found.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Deleting Rows that Match/Contain Search Criteria

This will go thru all the cells in column A, find the cells containing the
string "74RM" and delete the entire row. If non are found, no rows are
deleted:


Sub posse()
Dim lastrow As Long
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
For i = lastrow To 1 Step -1
If InStr(Cells(i, "A").Value, "74RM") 0 Then
Cells(i, "A").EntireRow.Delete
End If
Next
End Sub



--
Gary's Student
gsnu200707


"Posse John" wrote:

I import data for an external source into Excel. I sort and format the data
programatically.

This data contains some information that I need to delete. Searching that
range by using the following:

Columns("A:A").Find(What:="74RM",... ).Activate

How do I delete the entire row when the search criteria is found? I'm also
having difficulty understanding how to trap the error that occurs when the
search critieria is not found.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Deleting Rows that Match/Contain Search Criteria



set rng = Columns("A:A").Find(What:="74RM",... )
if not rng is nothing then
rng.EntireRow.Delete
End if

--
Regards,
Tom Ogilvy


"Posse John" wrote:

I import data for an external source into Excel. I sort and format the data
programatically.

This data contains some information that I need to delete. Searching that
range by using the following:

Columns("A:A").Find(What:="74RM",... ).Activate

How do I delete the entire row when the search criteria is found? I'm also
having difficulty understanding how to trap the error that occurs when the
search critieria is not found.

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
Match with 2 Lookup_Values used as search criteria. Sigmaz Excel Worksheet Functions 4 March 23rd 05 03:03 AM
Match with 2 Lookup_Values used as search criteria. Sigmaz Excel Worksheet Functions 0 March 21st 05 08:13 PM
Match with 2 Lookup_Values used as search criteria. Sigmaz Excel Worksheet Functions 0 March 21st 05 08:13 PM
Deleting rows which match filter Fred Smith Excel Programming 2 February 13th 04 02:24 AM


All times are GMT +1. The time now is 09:37 PM.

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"