ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   If cell contains a pattern delete the row (https://www.excelbanter.com/excel-programming/340402-if-cell-contains-pattern-delete-row.html)

John Smith

If cell contains a pattern delete the row
 
I would like to delete a row if a cell (say "F") contains a
certain pattern (say "abc"). Example:

If cell F of row 125 is "bcabcdd" it should be deleted.

How can this be done?

Nigel

If cell contains a pattern delete the row
 
When you say delete the row, if you mean delete the contents then use option
1 below, if you mean delete the contents
and remove the space created use option 2.


' option 1
If Range("F125") = "bcabcdd" Then Rows(125).ClearContents

'option 2
If Range("F125") = "bcabcdd" Then Rows(125).Delete Shift:=xlUp

--
Cheers
Nigel



"John Smith" wrote in message
...
I would like to delete a row if a cell (say "F") contains a
certain pattern (say "abc"). Example:

If cell F of row 125 is "bcabcdd" it should be deleted.

How can this be done?




Bob Phillips[_6_]

If cell contains a pattern delete the row
 
If Range("F2").Value Like "*abc*" Then
Range("F2").EntireRow.Delete
End If

--
HTH

Bob Phillips

"John Smith" wrote in message
...
I would like to delete a row if a cell (say "F") contains a
certain pattern (say "abc"). Example:

If cell F of row 125 is "bcabcdd" it should be deleted.

How can this be done?





All times are GMT +1. The time now is 07:23 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com