Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
Copying Select Repeating Cells in a Column
How would I go about creating a macro to select and copy certain cells in a
column and get them to paste in a blank column back-to-back (ie: selecting every fourth cell in a column and pasting it one after another in a new column)? I tried finding something like this in these and other discussion groups, but I'm not sure what to even call it, so my ability to find what I'm trying to describe on my own is virtually nonexistent. Any help would be greatly appreciated. |
#2
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
Copying Select Repeating Cells in a Column
If you have a row of data say in column A and you want to paste every 4th
data point into B, starting with row 1, your code would look something like: Sub everyFourth() Dim i As Integer Dim j As Integer j = 1 For i = 1 To 30 Cells(i, 2).Value = Cells(j, 1).Value j = j + 4 Next i End Sub This code goes through 30 rows in A. This number can be adjusted to suit your needs. "Shalebot" wrote: How would I go about creating a macro to select and copy certain cells in a column and get them to paste in a blank column back-to-back (ie: selecting every fourth cell in a column and pasting it one after another in a new column)? I tried finding something like this in these and other discussion groups, but I'm not sure what to even call it, so my ability to find what I'm trying to describe on my own is virtually nonexistent. Any help would be greatly appreciated. |
#3
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
Copying Select Repeating Cells in a Column
Here's a basic setup of a macro with commented setup to help you out. Just
plug this into a macro, change your options as needed/desired, and you should be good to go. Sub CopyCells() Dim xDest As Range, xStart As Range 'Starting cell Set xStart = Range("A2") 'Start of destination Set xDest = Range("B2") 'How many rows to skip each time? OffsetRule = 4 'How many cells to copy, not counting start cell? xAmount = 3 'Begin data copying xDest.Value = xStart.Value For i = 1 To xAmount xDest.Offset(i, 0).Value = xStart.Offset(i * OffsetRule, 0).Value Next End Sub -- Best Regards, Luke M *Remember to click "yes" if this post helped you!* "Shalebot" wrote: How would I go about creating a macro to select and copy certain cells in a column and get them to paste in a blank column back-to-back (ie: selecting every fourth cell in a column and pasting it one after another in a new column)? I tried finding something like this in these and other discussion groups, but I'm not sure what to even call it, so my ability to find what I'm trying to describe on my own is virtually nonexistent. Any help would be greatly appreciated. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Copying a column list from one sheet to another and repeating??? | Excel Worksheet Functions | |||
How to select certain cells in a column ? | Excel Discussion (Misc queries) | |||
repeating data in column to empty cells below without overwriting | Excel Worksheet Functions | |||
Copying a column of single cells into a column of merged cells | Excel Discussion (Misc queries) | |||
Copying different repeating entries down a column | Excel Discussion (Misc queries) |