ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Need Help with Deleting Rows (https://www.excelbanter.com/excel-programming/373249-need-help-deleting-rows.html)

[email protected]

Need Help with Deleting Rows
 
I want to delete rows
ie one row that has a certain no in a certain column like 1 in column A

and the next 6 rows that follow

my problem is that this repeats itself many times in the excel sheet
and i am not sure how many times as it varies

so i would like to have a macro which does that


thank you in advance


Regards

Indraneel


Tom Ogilvy

Need Help with Deleting Rows
 
Sub DeleteRows()
Dim lastrow as Long, i as Long
Dim cell as Range
lastrow = cells(rows.count,1).End(xlup)
for i = lastrow to 1 step -1
set cell = cells(i,1)
if cell = 1 then
cell.Resize(7,1).EntireRow.Delete
end if
Next
End Sub

--
Regards,
Tom Ogilvy



" wrote:

I want to delete rows
ie one row that has a certain no in a certain column like 1 in column A

and the next 6 rows that follow

my problem is that this repeats itself many times in the excel sheet
and i am not sure how many times as it varies

so i would like to have a macro which does that


thank you in advance


Regards

Indraneel




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

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