Copy Paste Range until selected cell reached

zachm85

New Member
Joined
Jul 30, 2012
Messages
6
I am trying to copy down 29 lines repetitively until I reach a center cell. However I can not seem to get the lines to continue copying past the initial paste.

How do I make this loop so it will continue to the last cell desired?

Sub Copy()
Dim rng As Range

Set rng = Range("b2:b29")

For Each row In rng.Rows
For Each cell In row.Cells
rng.Select
Selection.Copy
Next cell
Range("B30:B300").Select
ActiveSheet.Paste
Next
End Sub


Thank you.
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
How is the "last cell desired" determined?
 
Upvote 0
If you really mean to stop at the selected (active) cell, try this (note you can also hard-code the value).
This is set up so it can easily be adjusted for any numbers or rows in any column starting at any point:
Code:
Sub MyCopy()

    Dim myCol As String
    Dim myStartRow As Long
    Dim myJump As Long
    Dim myLastRow As Long
    Dim myEndPoint As Long
    
'   ***SET VALUES***
    myCol = "B"
    myStartRow = 2
    myJump = 28
'    myEndPoint = 100
    myEndPoint = ActiveCell.Row     'choose row of active cell for end point
    
    Application.ScreenUpdating = True
    
'   Loop
    Do
'       Find last row
        myLastRow = myStartRow + myJump - 1
'       Copy to next section if below end point, else exit
        If myStartRow + myJump < myEndPoint Then
            Range(Cells(myStartRow, myCol), Cells(myLastRow, myCol)).Copy Cells(myStartRow + myJump, myCol)
        Else
            Exit Do
        End If
'       Bump up start row
        myStartRow = myStartRow + myJump
    Loop
    
    Application.ScreenUpdating = True
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top