ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   VBA Code for Deleting a Row (https://www.excelbanter.com/excel-worksheet-functions/157182-vba-code-deleting-row.html)

[email protected]

VBA Code for Deleting a Row
 
I would like to use a macro to delete any row that has the word
"delete" in one of its cells. What would this code be? Thanks!


Gary''s Student

VBA Code for Deleting a Row
 
Sub zero()
Set r = ActiveSheet.UsedRange
nLastRow = r.Rows.Count + r.Row - 1
For i = nLastRow To 1 Step -1
For j = 1 To Columns.Count
v = Cells(i, j).Value
If InStr(1, v, "delete") 0 Then
Cells(i, j).EntireRow.Delete
Exit For
End If
Next
Next
End Sub

--
Gary''s Student - gsnu200742


" wrote:

I would like to use a macro to delete any row that has the word
"delete" in one of its cells. What would this code be? Thanks!



Don Guillett

VBA Code for Deleting a Row
 
Try recording a macro
datafilterautofilterfilter on deletedeleteautofiter
or
look in the vba help index for FINDNEXT.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

wrote in message
ups.com...
I would like to use a macro to delete any row that has the word
"delete" in one of its cells. What would this code be? Thanks!



Ron de Bruin

VBA Code for Deleting a Row
 
See also this page
http://www.rondebruin.nl/delete.htm


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


wrote in message ups.com...
I would like to use a macro to delete any row that has the word
"delete" in one of its cells. What would this code be? Thanks!



All times are GMT +1. The time now is 01:48 AM.

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