Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 151
Default 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   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,722
Default 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
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
Copying a column list from one sheet to another and repeating??? simon Excel Worksheet Functions 18 April 22nd 09 08:06 PM
How to select certain cells in a column ? Mark246 Excel Discussion (Misc queries) 1 February 25th 08 10:08 PM
repeating data in column to empty cells below without overwriting jeffchina Excel Worksheet Functions 1 April 26th 07 05:50 PM
Copying a column of single cells into a column of merged cells [email protected] Excel Discussion (Misc queries) 1 August 16th 06 01:18 PM
Copying different repeating entries down a column Access Joe Excel Discussion (Misc queries) 2 January 13th 06 02:34 PM


All times are GMT +1. The time now is 10:32 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"