Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Delete 2 rows skip 1 delete 2 more

I am looking to have a macro delete 2 rows then skip 1 row and delete
the next two. I have over 18,000 rows and I really would rather not do
this the manual way. :)

Thanks,
Jared

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 170
Default Delete 2 rows skip 1 delete 2 more

I know you said you wanted a macro, but if you are only doing this once, it
only takes 30 seconds to do it manually:

- Add a helper column
- In the 1st three cells of that column enter A, B, C.
- Copy those 3 cells down the length of your data
- Sort on the Helper column.
- Delete A's & B's

HTH,
--
George Nicholson

Remove 'Junk' from return address.


"jared" wrote in message
oups.com...
I am looking to have a macro delete 2 rows then skip 1 row and delete
the next two. I have over 18,000 rows and I really would rather not do
this the manual way. :)

Thanks,
Jared



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Delete 2 rows skip 1 delete 2 more

Sub DeleteRows()
Columns(1).Insert
Range("A1:A18500").Formula = "=if(mod(row(),3)=0,""Keep"",na())"
set rng = Columns(1).SpecialCells(xlFormulas,xlErrors).Entir eRow.Delete
columns(1).Delete
End Sub

--
Regards,
Tom Ogilvy


"jared" wrote in message
oups.com...
I am looking to have a macro delete 2 rows then skip 1 row and delete
the next two. I have over 18,000 rows and I really would rather not do
this the manual way. :)

Thanks,
Jared



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Delete 2 rows skip 1 delete 2 more

Jared,

This might be what you want

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

iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
If iLastRow Mod 3 < 1 Then iLastRow = iLastRow - 1
If iLastRow Mod 3 < 1 Then iLastRow = iLastRow - 1
For i = iLastRow To 1 Step -3
Rows(i).Resize(2).Delete
Next i

End Sub


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"jared" wrote in message
oups.com...
I am looking to have a macro delete 2 rows then skip 1 row and delete
the next two. I have over 18,000 rows and I really would rather not do
this the manual way. :)

Thanks,
Jared



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Quick Macro question - How to delete two rows then skip one - and repeat David Smithz Excel Discussion (Misc queries) 3 March 3rd 06 02:58 PM
Macro to delete sheets and saves remaining file does not properly delete module pherrero Excel Programming 1 June 22nd 05 01:12 AM
Macro to delete sheets and saves remaining file does not properly delete module bhawane Excel Programming 0 June 21st 05 04:20 PM
How to delete rows when List toolbar's "delete" isnt highlighted? Linda Excel Worksheet Functions 1 May 26th 05 08:39 PM
Delete every 3rd row, then delete rows 2-7, move info f/every 2nd row up one to the end and delete the row below Annette[_4_] Excel Programming 2 September 21st 04 02:40 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"