LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default macro to cut/ paste ever nth row

I'm thinking there is a really simple solution that I am missing for
this problem. I have an excel file with a couple thousand records. I
need to be able to select every nth row (starting with row 1), cut
that row from the sheet and paste it into sheet 2, continuing until it
reaches an empty row. Example:
A B C
1 u t s
2 e r q
3 c p u
4 c o t
5 v u b
6 9 7 8
7 b 5 8
8 o e 3
9 8 4 c
10 i e b
11 9 e 4

Using 5 as the nth, the macro would cut rows 1, 6, 11, etc.... into
sheet 2. Sheet 1 would look like:
A B C
1 e r q
2 c p u
3 c o t
4 v u b
5 b 5 8
6 o e 3
7 8 4 c
8 i e b


And sheet 2 would have
A B C
1 u t s
2 9 7 8
3 9 e 4



I have the following code which will do copy the nth rows, but it
leaves them in the original document.

Sub copyNthRow()
Dim j As Integer
Dim i As Integer
Dim NthRow As Integer

NthRow = 5
j = Cells.SpecialCells(xlLastCell).Row
Range("A1").Select
Do Until ActiveCell.Row j
Rows(ActiveCell.Row).Copy
Sheets("sheet3").Range("A1").Offset(i, 0).PasteSpecial
(xlValues)
i = i + 1
ActiveCell.Offset(NthRow, 0).Select
Loop
End Sub

I need a way to remove them from that document. I'm willing to run two
macros if that's what I need to do, one to copy and then one to cut...
any help:

 
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
copy multiple worksheets of a workbook, and paste onto a Word document ( either create new doc file or paste onto an existing file.) I need this done by VBA, Excel Macro Steven Excel Programming 1 October 17th 05 08:56 AM
Copy and Paste macro needs to paste to a changing cell reference loulou Excel Programming 0 February 24th 05 10:29 AM
Cut and Paste using Macro gives paste special method error Lourens Pentz Excel Programming 3 November 21st 04 10:42 PM
Macro to Paste to specific line, and continue to Paste each time on next row not over tomkarakowski[_2_] Excel Programming 1 May 28th 04 06:50 PM
Macro to Copy/Paste then Paste to Next Line tomkarakowski Excel Programming 1 May 28th 04 01:19 AM


All times are GMT +1. The time now is 10: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"