ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   How do I delete every other line in an Excel document with over 3. (https://www.excelbanter.com/excel-discussion-misc-queries/2394-how-do-i-delete-every-other-line-excel-document-over-3-a.html)

Darren

How do I delete every other line in an Excel document with over 3.
 
I have a rather large document where I need to delete every other line
beginning with line 8. I am looking for a shortcut rather than manually
deleting each line.

Frank Kabel

Hi
this would require VBA or you may try the following procedure
in B1 put the following formula:
=MOD(ROW(),2)
and copy this down for all rows.
Now apply an autofilter and filter out every 1 or 0 and afterwards delete
the filtered rows

--
Regards
Frank Kabel
Frankfurt, Germany

Darren wrote:
I have a rather large document where I need to delete every other line
beginning with line 8. I am looking for a shortcut rather than
manually deleting each line.




Jason Morin

Try this macro:

Sub DeleteRows()

Dim iLastRow As Integer
Dim i As Integer
Dim iRem As Integer

Application.ScreenUpdating = False

iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
iRem = iLastRow Mod 2

If iRem = 1 Then
iLastRow = iLastRow + 1
Else
iLastRow = iLastRow
End If

For i = iLastRow To 8 Step -2
Cells(i, "A").EntireRow.Delete
Next i

Application.ScreenUpdating = True

End Sub

---
HTH
Jason
Atlanta, GA

-----Original Message-----
I have a rather large document where I need to delete

every other line
beginning with line 8. I am looking for a shortcut

rather than manually
deleting each line.
.


Alan Beban

Darren wrote:
I have a rather large document where I need to delete every other line
beginning with line 8. I am looking for a shortcut rather than manually
deleting each line.


If the functions in the freely downloadable file at
http://home.pacbell.net are available to your workbook, then assuming
your data is on Sheet1 in Columns A:K

Array enter into A1:K7 of an empty sheet =Sheet1!A1:K7

and array enter into A8:A[whatever] of that sheet
=ArrayAlternates(Sheet1!A8:K[whatever],False)

Alan Beban


All times are GMT +1. The time now is 09:15 PM.

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