ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Delete rows (https://www.excelbanter.com/excel-programming/305854-delete-rows.html)

fl

Delete rows
 
If the cell value = "ABC" on column A, then I need to delete that row
and the next two rows. What is the formula to do that?


Frank Kabel

Delete rows
 
Hi
try the following macro:
Sub delete_rows()
Dim lastrow As Long
Dim row_index As Long
Application.ScreenUpdating = False
lastrow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
For row_index = lastrow - 1 To 1 Step -1
If Cells(row_index, 1).Value = "ABC" then
cells(row_index,1).resize(3,1).entirerow.delete
End If
Next
Application.ScreenUpdating = True
End Sub

--
Regards
Frank Kabel
Frankfurt, Germany


fl wrote:
If the cell value = "ABC" on column A, then I need to delete that row
and the next two rows. What is the formula to do that?




All times are GMT +1. The time now is 05:42 PM.

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