copying every nth cell value to another cell in order

smashgear

New Member
Joined
Feb 9, 2005
Messages
9
Guys, I need help on this. Can someone lend a hand?

What I did was I have a series of speed data recorded per second. I wanted a speed data for every 15 minutes, so I was able to find a VB code to select every 900th speed data.

The thing is, the data is too large to navigate manually and copy the selected values and group them into another column, right next to each other.

Anyone can help? Thanks in advance.

Here is how it looks (example, every 3rd value):

ed44bce3-6d3f-4f94-992f-8f12dcf935c7
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

ADAMC

Well-known Member
Joined
Mar 20, 2007
Messages
1,169
Office Version
  1. 2013
Platform
  1. Windows
Is this what your looking for?

You need to highlight all the columns in your range:
Code:
Sub PullEveryNthRow()

' Pull every Nth row from the selected range and place those values in
' a new worksheet.

   Dim Increment As Long
   Dim Source As Range
   Dim TargetSheet As Worksheet
   Dim SourceRow As Long
   Dim TargetRow As Long
   
   ' Use the current selection for the source
   Set Source = Selection
   
   ' Query user for the increment
   Do
      Increment = InputBox("Enter increment:")
      If Increment < 1 Then
         Exit Sub
      End If
   Loop Until Increment > 0

   ' Add a new sheet and move the data
   Sheets.Add
   Set TargetSheet = ActiveSheet
   TargetRow = 1
   For SourceRow = 1 To Source.Rows.Count Step Increment
      TargetSheet.Rows(TargetRow). _
         Resize(1, Source.Columns.Count).Value _
         = Source.Rows(SourceRow).Value
      TargetRow = TargetRow + 1
   Next SourceRow

End Sub

When the enter incriment box appears selecting 3 would copy every 3rd row and paste it to a new sheet but not sure if this is what you need?

Not my work..One of the guys in my office wrote this for me but hope it helps.
 

smashgear

New Member
Joined
Feb 9, 2005
Messages
9
Is this what your looking for?

You need to highlight all the columns in your range:
Code:
Sub PullEveryNthRow()

' Pull every Nth row from the selected range and place those values in
' a new worksheet.

   Dim Increment As Long
   Dim Source As Range
   Dim TargetSheet As Worksheet
   Dim SourceRow As Long
   Dim TargetRow As Long
   
   ' Use the current selection for the source
   Set Source = Selection
   
   ' Query user for the increment
   Do
      Increment = InputBox("Enter increment:")
      If Increment < 1 Then
         Exit Sub
      End If
   Loop Until Increment > 0

   ' Add a new sheet and move the data
   Sheets.Add
   Set TargetSheet = ActiveSheet
   TargetRow = 1
   For SourceRow = 1 To Source.Rows.Count Step Increment
      TargetSheet.Rows(TargetRow). _
         Resize(1, Source.Columns.Count).Value _
         = Source.Rows(SourceRow).Value
      TargetRow = TargetRow + 1
   Next SourceRow

End Sub

When the enter incriment box appears selecting 3 would copy every 3rd row and paste it to a new sheet but not sure if this is what you need?

Not my work..One of the guys in my office wrote this for me but hope it helps.


this is it! wow thanks.. i used it already. thanks for posting it.

greetings!
 

Forum statistics

Threads
1,181,719
Messages
5,931,660
Members
436,797
Latest member
fullmetalpogi

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top