ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Find and Delete Row (https://www.excelbanter.com/excel-worksheet-functions/162271-find-delete-row.html)

Keyrookie

Find and Delete Row
 
Need some help...

I'm trying to find ANY text in a column and then delete the entire row. In other words, if there is text in B3, B8, B16, etc., I want to find the macro to find it and then delete the rows 3, 8, 16, etc. These are not actual rows, just examples. I tried the following macro but it doesn't work. I tried to use a wildcard character to locate text in column B because that text is not a constant. I think I'm close but I need this to be corrected.

Thanks for your help.

Sub Delete_Zero_Rows()
Dim lastrow As Long, r As Long
lastrow = Cells(Rows.Count, "B").End(xlUp).Row
For r = lastrow To 1 Step -1
If Cells(r, "B") = (item*) Then
Rows(r).EntireRow.Delete
End If
Next r
End Sub

Gary''s Student

Find and Delete Row
 
Sub Delete_Zero_Rows()
Dim lastrow As Long, r As Long
lastrow = Cells(Rows.Count, "B").End(xlUp).Row
For r = lastrow To 1 Step -1
If Application.WorksheetFunction.IsText(Cells(r, "B")) Then
Rows(r).EntireRow.Delete
End If
Next r
End Sub
--
Gary''s Student - gsnu200750


"Keyrookie" wrote:


Need some help...

I'm trying to find ANY text in a column and then delete the entire row.
In other words, if there is text in B3, B8, B16, etc., I want to find
the macro to find it and then delete the rows 3, 8, 16, etc. These are
not actual rows, just examples. I tried the following macro but it
doesn't work. I tried to use a wildcard character to locate text in
column B because that text is not a constant. I think I'm close but I
need this to be corrected.

Thanks for your help.

Sub Delete_Zero_Rows()
Dim lastrow As Long, r As Long
lastrow = Cells(Rows.Count, "B").End(xlUp).Row
For r = lastrow To 1 Step -1
If Cells(r, "B") = (item*) Then
Rows(r).EntireRow.Delete
End If
Next r
End Sub




--
Keyrookie



All times are GMT +1. The time now is 11:00 PM.

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