VBA - Copy past to the last row

mariab9

New Member
Joined
Feb 14, 2022
Messages
4
Office Version
  1. 2016
Platform
  1. Windows
  2. Web
Hi,

I'm having problems to find the right "language" to set this in VBA:

I want to copy and paste from one range to the last one with data. The number of ranges will change every day as there will be more or less data.

In the image attached, I want to copy Range("c2) to the last one, which is "c16" in this case. How can I do it in VBA.

I tried end(xldown) but it paste it until the last existing range in C, which contains blank cells and I don't want that.

Can someone help me, please?
 

Attachments

  • Capture.PNG
    Capture.PNG
    35.4 KB · Views: 123

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Hi,

I'm having problems to find the right "language" to set this in VBA:

I want to copy and paste from one range to the last one with data. The number of ranges will change every day as there will be more or less data.

In the image attached, I want to copy Range("c2) to the last one, which is "c16" in this case. How can I do it in VBA.

I tried end(xldown) but it paste it until the last existing range in C, which contains blank cells and I don't want that.

Can someone help me, please?
where are you wanting to paste the information?
 
Upvote 0
Excel Formula:
range("C2:C" & range("C" & Rows.count).End(xlUp).Row).copy
this will copy column "C" from C2 to the last row of data
 
Upvote 0
Excel Formula:
range("C2:C" & range("C" & Rows.count).End(xlUp).Row).copy
this will copy column "C" from C2 to the last row of data
Hi,
Thanks for your answer. However the formula you sent me just copy it. How would be the paste? I also only want to copy C2 and then paste to the last.

Wouldn't it be range("C2").copy range("C2:C" & range("C" & Rows.count).End(xlUp).Row) ?
 
Upvote 0
Hi,
Thanks for your answer. However the formula you sent me just copy it. How would be the paste? I also only want to copy C2 and then paste to the last.

Wouldn't it be range("C2").copy range("C2:C" & range("C" & Rows.count).End(xlUp).Row) ?
no if you want to paste range("C2") AFTER the last row in column "C" you would need to Lose the second "C" in the range and also +1 to the last row reference.
The code would be

VBA Code:
range("C2").Copy range("C" & range("C" & Rows.count).End(xlUp).Row + 1)
 
Upvote 0
Hi,

I want to paste C2 to C3 and all the rows that come after that, having into account that everyday C row numbers change.

I am not looking to paste it after the last row. I want to paste from C2 till the last raw with data. Would then be the same?
 
Upvote 0
Hi,

I want to paste C2 to C3 and all the rows that come after that, having into account that everyday C row numbers change.

I am not looking to paste it after the last row. I want to paste from C2 till the last raw with data. Would then be the same?
That’s slightly different to your original request. I think what your asking for is to take the value of c2 and paste it to the last row with data (value would need to come from the neighbouring columns as c2 is the last row with data in column c). If so you have two options

VBA Code:
range("C2:C" & range("B" & Rows.count).End(xlUp).Row).FillDown

VBA Code:
range("C2").Copy range("C3:C" & range("B" & Rows.count).End(xlUp).Row)
 
Upvote 0
Solution
That’s slightly different to your original request. I think what your asking for is to take the value of c2 and paste it to the last row with data (value would need to come from the neighbouring columns as c2 is the last row with data in column c). If so you have two options

VBA Code:
range("C2:C" & range("B" & Rows.count).End(xlUp).Row).FillDown

VBA Code:
range("C2").Copy range("C3:C" & range("B" & Rows.count).End(xlUp).Row)
Now it's working! :D

Many thanks
 
Upvote 0

Forum statistics

Threads
1,214,812
Messages
6,121,693
Members
449,048
Latest member
81jamesacct

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