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. |
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. |
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. |
All times are GMT +1. The time now is 08:13 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com