![]() |
How to move every nth value in a column
How can I move every 5th value in a column of data to another
worksheet? Also, Is it possible to define a start/stop point for this? Any help is greatly appreciated. |
How to move every nth value in a column
Hi,
Please try this macro. Sub Move_Every_Fifth() Dim LastRow As Long, LastRowDestSheet As Long Dim i As Long, srcSht As Worksheet Dim DestSht As Worksheet Set srcSht = ActiveSheet Set DestSht = Sheets("Sheet2") LastRow = srcSht.Cells(Rows.Count, 1).End(xlUp).Row For i = 1 To LastRow Step 5 If i = 1 Then LastRowDestSheet = DestSht.Cells(DestSht.Rows.Count, 1).End(xlUp).Row Else LastRowDestSheet = DestSht.Cells(DestSht.Rows.Count, 1).End(xlUp).Row + 1 End If DestSht.Cells(LastRowDestSheet, 1).Value = Cells(i, 1).Value Next i End Sub If you need any help with this please revert. -- Anant " wrote: How can I move every 5th value in a column of data to another worksheet? Also, Is it possible to define a start/stop point for this? Any help is greatly appreciated. |
How to move every nth value in a column
This can be done without VBA:
In a helper column near your dta enter: =MOD(ROW(),5) and copy down. You should see a sequence like: 2 3 4 0 1 2 3 4 0 1 2 3 etc. (not necessarily starting with 2). Then switch on AutoFilter. You can then select every fifth line for copy/paste with arbitrary phasing. -- Gary's Student " wrote: How can I move every 5th value in a column of data to another worksheet? Also, Is it possible to define a start/stop point for this? Any help is greatly appreciated. |
All times are GMT +1. The time now is 02:54 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com