Code to delete lines according to order condition

Excelpromax123

Board Regular
Joined
Sep 2, 2021
Messages
167
Office Version
  1. 2010
Platform
  1. Windows
Hello everyone. I have a spreadsheet with nearly 2000 lines, I want to delete lines 8,9,10 and 18,19,20 ( Keep the first 7 lines, delete the next 3 and repeat )
... how should I use the code? Please everyone help. I sincerely thank you
Link: Loading Google Sheets
1659174000110.png
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Providing that you don't have tens of thousands of rows, try this with a copy of your data.

VBA Code:
Sub DelRows()
  Dim r As Long
 
  Application.ScreenUpdating = False
  For r = Int(Range("B" & Rows.Count).End(xlUp).Row / 10) * 10 - 2 To 8 Step -10
    Rows(r).Resize(3).Delete
  Next r
  Application.ScreenUpdating = True
End Sub
 
Upvote 0
Solution
Providing that you don't have tens of thousands of rows, try this with a copy of your data.

VBA Code:
Sub DelRows()
  Dim r As Long
 
  Application.ScreenUpdating = False
  For r = Int(Range("B" & Rows.Count).End(xlUp).Row / 10) * 10 - 2 To 8 Step -10
    Rows(r).Resize(3).Delete
  Next r
  Application.ScreenUpdating = True
End Sub
Thank You
 
Upvote 0

Forum statistics

Threads
1,214,982
Messages
6,122,580
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top