Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Amy Amy is offline
external usenet poster
 
Posts: 165
Default Macro to pull every Nth row of data

I have a spreadsheet of data and I need to pull every 60th row out onto
another sheet. Any simple macros?

Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 661
Default Macro to pull every Nth row of data

Amy

How about

Sub Test()
Source_Sheet = "Sheet1"
Target_Sheet = "Sheet2"

n = 5000 ' your last line of data on Sheet1
Target_Row = 1
Sheets(Target_Sheet).Select
For nCount = 1 To n Step 60

Worksheets(Source_Sheet).Cells(nCount, 1).EntireRow.Copy
Worksheets(Target_Sheet).Cells(Target_Row, 1).Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=False
Target_Row = Target_Row + 1
Next

End Sub

I've used paste values here so that calculations on your first sheet are not
compromised in the second

"Amy" wrote:

I have a spreadsheet of data and I need to pull every 60th row out onto
another sheet. Any simple macros?

Thanks.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 896
Default Macro to pull every Nth row of data

you don't need a macro to achieve that

provided the data is in Sheet1!A1:A100 in Sheet2!B1 try this formula:

=OFFSET(Sheet1!$A$1,ROW()*60-1,)

drag down


On 19 Lis, 14:43, Amy wrote:
I have a spreadsheet of data and I need to pull every 60th row out onto
another sheet. Any simple macros?

Thanks.


  #4   Report Post  
Posted to microsoft.public.excel.programming
Amy Amy is offline
external usenet poster
 
Posts: 165
Default Macro to pull every Nth row of data

Many thanks to all...

This worked best for me.


Sub copyalternaterows()
Dim ds As Worksheet
Dim r As Long
Dim i As Long
Set ds = Sheets("Sheet6") 'destination
With Sheets("sheet7") ' source
r = 2
For i = 1 To .Cells(Rows.Count, 1).End(xlUp).Row Step 60
..Rows(i).Copy ds.Rows(r)
r = r + 1
Original Source: The Code Cage Forums
http://www.thecodecage.com/forumz/ex...tml#post563506
Next i
End With
End Sub
--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Amy" wrote in message
...
I have a spreadsheet of data and I need to pull every 60th row out onto
another sheet. Any simple macros?

Thanks.


I didn't go with the Offset fx because I have about 20 worksheets a week
that need this and I just want to push a button and it be done.

Thanks again.
Amy



"Jarek Kujawa" wrote:

you don't need a macro to achieve that

provided the data is in Sheet1!A1:A100 in Sheet2!B1 try this formula:

=OFFSET(Sheet1!$A$1,ROW()*60-1,)

drag down


On 19 Lis, 14:43, Amy wrote:
I have a spreadsheet of data and I need to pull every 60th row out onto
another sheet. Any simple macros?

Thanks.


.

  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Macro to pull every Nth row of data

Sub copyalternaterows()
Dim ds As Worksheet
Dim r As Long
Dim i As Long
Set ds = Sheets("Sheet6") 'destination
With Sheets("sheet7") ' source
r = 2
For i = 1 To .Cells(Rows.Count, 1).End(xlUp).Row Step 60
.Rows(i).Copy ds.Rows(r)
r = r + 1
Next i
End With
End Sub
--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Amy" wrote in message
...
I have a spreadsheet of data and I need to pull every 60th row out onto
another sheet. Any simple macros?

Thanks.


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
Macro to pull data with criterea for placement on a new sheet Trina Excel Discussion (Misc queries) 7 June 13th 08 11:00 PM
Macro to Pull data from multiple excel sheets Chinmaybl Excel Programming 2 March 2nd 07 05:58 AM
Macro to Pull Data from Seperate Workbooks Martin Fishlock Excel Programming 5 December 19th 06 04:28 AM
Macro to Pull Data from Seperate Workbooks Martin Fishlock Excel Programming 0 December 19th 06 01:11 AM
macro won't pull up list's data form Randall[_4_] Excel Programming 1 February 23rd 04 08:18 PM


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