ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro to delete rows (https://www.excelbanter.com/excel-programming/308150-macro-delete-rows.html)

steve

Macro to delete rows
 
I have a list that i am copying and pasting from a
different location with entirely too much information. I
am looking for a macro to delete 3 rows, leave the 4th,
delete the next 3 and so on. For example: Starting at row
23, leave 23, delete row 24, 25, 26, leave row 27, delete
row 28, 29 and 30, and so on and so forth over a given
range. Can anyone help?


Thanks for your time,
Steve

Don Lloyd

Macro to delete rows
 
Hi Steve,

Sub Test()
Dim Rw, LastRw, Rw3 As String
Rw = 23 ' 1st row
LastRw = 123 ' last row in range
Do
Rw3 = Rw + 1 & ":" & Rw + 3
Rows(Rw3).Delete
Rw = Rw + 1
LastRw = LastRw - 3
Loop Until Rw = LastRw
End Sub

regards,
Don

"Steve" wrote in message
...
I have a list that i am copying and pasting from a
different location with entirely too much information. I
am looking for a macro to delete 3 rows, leave the 4th,
delete the next 3 and so on. For example: Starting at row
23, leave 23, delete row 24, 25, 26, leave row 27, delete
row 28, 29 and 30, and so on and so forth over a given
range. Can anyone help?


Thanks for your time,
Steve





All times are GMT +1. The time now is 02:06 PM.

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