Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / May 2008

Tip: Looking for answers? Try searching our database.

Copy and paste every x number of cells

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mike - 22 May 2008 20:50 GMT
So I think I am stuck and need some help.
I have a list of numbers and want to duplicate a number every so many cells
keeping the duplicate in the list. I have figured out how to insert 2 blank
lines every 20 cells but now need to copy the cell after the blank cells and
paste it into the first blank cell  

i.e  I have inserted 2 blank cells at A10 and A11 moving the list down, now
I want to copy the contents of cell A132 (the old A10) and paste it in the
blank A10.  

I am sure there is an easy way to do this but I am stuck….any help would be
great!

Thanks
ND Pard - 22 May 2008 22:29 GMT
Mike,

Here is a macro that should do the job for you.

Good Luck.

***********************************

Option Explicit

Sub InsertRows_n_CopyCell()

'Select the starting row ...
'this example assumes it is cell A7
 Range("A7").Select

'Start a Looping procedure
 Do While ActiveCell.Value > " "

'Move down 20 rows
 ActiveCell.Offset(20).Select

'Insert 2 rows by
'Selecting the current row and
'the row below the current row
 Range(ActiveCell, ActiveCell.Offset(1)).Select
 Selection.EntireRow.Insert , _
   CopyOrigin:=xlFormatFromLeftOrAbove

'Copy the data that is now down 2 rows
'into the Active Cell
 ActiveCell.Value = ActiveCell.Offset(2).Value

'Move the active cell down 2 rows
 ActiveCell.Offset(2).Select

Loop

End Sub

> So I think I am stuck and need some help.
> I have a list of numbers and want to duplicate a number every so many cells
[quoted text clipped - 10 lines]
>
> Thanks
Mike - 23 May 2008 13:33 GMT
Great!  Thanks for the code and even more so for the explanation with it!

Thanks again

> Mike,
>
[quoted text clipped - 50 lines]
> >
> > Thanks
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.