Deleting Lines

W

woodworker11

Large spreedsheet that I want to save my start line. step down 1 lin
and delete 29 line. Step down 1 line and delete 29 lines. Basicaly
want to save every 30th line. Continue this loop until encounter blan
line
 
M

Martin Brown

Large spreedsheet that I want to save my start line. step down 1 line
and delete 29 line. Step down 1 line and delete 29 lines. Basicaly I
want to save every 30th line. Continue this loop until encounter blank
line.

You will find it easier to find the last row and then save the one you
want and delete the 29 others working backwards to the first row.

That way the loop indexing doesn't renumber under your feet.
 
C

Claus Busch

Hi,

Am Fri, 10 May 2013 14:58:52 +0100 schrieb woodworker11:
Large spreedsheet that I want to save my start line. step down 1 line
and delete 29 line. Step down 1 line and delete 29 lines. Basicaly I
want to save every 30th line. Continue this loop until encounter blank
line.

you want to save line 30, 60, 90 etc.?
then try:

Sub Test()
Dim i As Long
Dim LRow As Long

LRow = Cells(Rows.Count, 1).End(xlUp).Row
For i = LRow To 2 Step -1
If i Mod 30 <> 0 Then
Rows(i).Delete
End If
Next
End Sub


Regards
Claus Busch
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top