Copy/Paste from next empty cell to last empty cell

josephmary

New Member
Joined
Oct 18, 2023
Messages
26
Office Version
  1. 365
Platform
  1. Windows
Hi,
I know this may be simple but I only know a few macros so I had to ask a question :)
As shown on the image, I need U2 to U12 (which is the sections 1.1 to 4.2) be copied and pasted from next empty cell up to the last empty cell
1697641903586.png
 

Attachments

  • Capture.JPG
    Capture.JPG
    31.1 KB · Views: 6

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Don't know if you realize, but this can be done by highlighting the range to be copied (from first cell to last) then click on the +sign in the corner of the last cell, hold ctrl key and drag down.
 
Upvote 0
Apologies if I wasn't clear enough. I wanted to write a macro that will do that automatically for me
 
Upvote 0
but i think i get what you're saying. i can just record the macro. i will try and get back to you. Thank you
 
Upvote 0
That range of cells, from U2 to U12, is exactly 11 cells.
When copy down this pattern, will the number of rows to copy to ALWAYS be an exact multiple of 11 (so you would also be copying a full set of these 11 values each time)?
 
Upvote 0
Try this:
VBA Code:
Sub MyCopy()

    Dim lrT As Long
    Dim rng As Range
    Dim r1 As Long
    Dim r2 As Long
    
    Application.ScreenUpdating = False
    
'   Find last row in column T with data
    lrT = Cells(Rows.Count, "T").End(xlUp).Row
    
'   Set range to copy from
    Set rng = Range("U2:U12")
    
'   Set initial values of r1 and r2
    r1 = 2
    r2 = 12
    
'   Loop until copied down enough times
    Do
'       Exit if copied down to last row of column T
        If lrT <= r2 Then
            Exit Sub
        End If
'       Increment row numbers by 11
        r1 = r1 + 11
        r2 = r2 + 11
'       Copy down
        rng.Copy Cells(r1, "U")
    Loop
    
    Application.ScreenUpdating = True
        
End Sub
 
Upvote 1
Solution

Forum statistics

Threads
1,215,129
Messages
6,123,218
Members
449,091
Latest member
jeremy_bp001

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