PC Review


Reply
Thread Tools Rate Thread

Copy (“A2:A26”) paste, offset one cell, do it again. Loop 256 tim

 
 
RyGuy
Guest
Posts: n/a
 
      22nd Oct 2009
I am trying to figure out a way to take a range (“A2:A26”) and copy/paste it
into range (“D5579”) then offset one cell down, then do it again, so
(“A2:A26”) copy/paste to (“D81105”) and so on and so forth. I want it to
run 256 times.

I am looking for a sample of code that I thought I had somewhere in my
library, but can’t seem to find it now. Any ideas?

Thanks,
Ryan--

 
Reply With Quote
 
 
 
 
Mike H
Guest
Posts: n/a
 
      22nd Oct 2009
Hi,

Try this

Sub Versive()
Range("A2:A26").Copy
For x = 55 To 1430 Step 26
Cells(x, 4).PasteSpecial
Next
End Sub

Mike

"RyGuy" wrote:

> I am trying to figure out a way to take a range (“A2:A26”) and copy/paste it
> into range (“D5579”) then offset one cell down, then do it again, so
> (“A2:A26”) copy/paste to (“D81105”) and so on and so forth. I want it to
> run 256 times.
>
> I am looking for a sample of code that I thought I had somewhere in my
> library, but can’t seem to find it now. Any ideas?
>
> Thanks,
> Ryan--
>

 
Reply With Quote
 
RyGuy
Guest
Posts: n/a
 
      22nd Oct 2009
Thanks! Very cool. This macro worked pretty well too:

Sub CopyDown()
Dim lstRw As Long
lstRw = Cells(Rows.Count, 1).End(xlUp).Row
Do Until lstRw >= 7000
ActiveCell.Resize(26, 1).Copy ActiveCell.Offset(26, 0)
lstRw = lstRw + 2
Range("A" & lstRw - 9).Activate
Loop
End Sub

It was off by one row, so I inserted one cell down, and everything lined up
nicely.

Hope this helps others.


Thanks again Mike!
Ryan--


"Mike H" wrote:

> Hi,
>
> Try this
>
> Sub Versive()
> Range("A2:A26").Copy
> For x = 55 To 1430 Step 26
> Cells(x, 4).PasteSpecial
> Next
> End Sub
>
> Mike
>
> "RyGuy" wrote:
>
> > I am trying to figure out a way to take a range (“A2:A26”) and copy/paste it
> > into range (“D5579”) then offset one cell down, then do it again, so
> > (“A2:A26”) copy/paste to (“D81105”) and so on and so forth. I want it to
> > run 256 times.
> >
> > I am looking for a sample of code that I thought I had somewhere in my
> > library, but can’t seem to find it now. Any ideas?
> >
> > Thanks,
> > Ryan--
> >

 
Reply With Quote
 
Mike H
Guest
Posts: n/a
 
      22nd Oct 2009
Got the end value for the loop wroong, try this

For x = 55 To 6701 Step 26

"Mike H" wrote:

> Hi,
>
> Try this
>
> Sub Versive()
> Range("A2:A26").Copy
> For x = 55 To 1430 Step 26
> Cells(x, 4).PasteSpecial
> Next
> End Sub
>
> Mike
>
> "RyGuy" wrote:
>
> > I am trying to figure out a way to take a range (“A2:A26”) and copy/paste it
> > into range (“D5579”) then offset one cell down, then do it again, so
> > (“A2:A26”) copy/paste to (“D81105”) and so on and so forth. I want it to
> > run 256 times.
> >
> > I am looking for a sample of code that I thought I had somewhere in my
> > library, but can’t seem to find it now. Any ideas?
> >
> > Thanks,
> > Ryan--
> >

 
Reply With Quote
 
Mike H
Guest
Posts: n/a
 
      22nd Oct 2009
Glad I could help and thanks for the feedback

"RyGuy" wrote:

> Thanks! Very cool. This macro worked pretty well too:
>
> Sub CopyDown()
> Dim lstRw As Long
> lstRw = Cells(Rows.Count, 1).End(xlUp).Row
> Do Until lstRw >= 7000
> ActiveCell.Resize(26, 1).Copy ActiveCell.Offset(26, 0)
> lstRw = lstRw + 2
> Range("A" & lstRw - 9).Activate
> Loop
> End Sub
>
> It was off by one row, so I inserted one cell down, and everything lined up
> nicely.
>
> Hope this helps others.
>
>
> Thanks again Mike!
> Ryan--
>
>
> "Mike H" wrote:
>
> > Hi,
> >
> > Try this
> >
> > Sub Versive()
> > Range("A2:A26").Copy
> > For x = 55 To 1430 Step 26
> > Cells(x, 4).PasteSpecial
> > Next
> > End Sub
> >
> > Mike
> >
> > "RyGuy" wrote:
> >
> > > I am trying to figure out a way to take a range (“A2:A26”) and copy/paste it
> > > into range (“D5579”) then offset one cell down, then do it again, so
> > > (“A2:A26”) copy/paste to (“D81105”) and so on and so forth. I want it to
> > > run 256 times.
> > >
> > > I am looking for a sample of code that I thought I had somewhere in my
> > > library, but can’t seem to find it now. Any ideas?
> > >
> > > Thanks,
> > > Ryan--
> > >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
vba; copy row, paste at offset md Microsoft Excel Programming 2 29th Mar 2008 07:44 PM
Find String in Cell then Paste Sum in Offset Cell RyanH Microsoft Excel Programming 1 23rd Jan 2008 02:06 AM
Last cell, copy, paste special, loop =?Utf-8?B?QUs=?= Microsoft Excel Programming 2 6th Feb 2007 11:57 PM
copy and paste with offset kevcar40 Microsoft Excel Misc 3 10th Oct 2005 03:20 PM
Copy & Paste+Offset Ronald Cayne Microsoft Excel Programming 2 7th Sep 2004 07:35 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:29 AM.