Copy and Paste VBA Help

shivam03

Board Regular
Joined
Nov 22, 2010
Messages
86
Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
<o:p></o:p>
Thanks for taking time to look at my issue.<o:p></o:p>
<o:p></o:p>
I have some VBA code which copies a row of data across many columns and pastes is across many rows.<o:p></o:p>
<o:p></o:p>
I have issue is that VBA cannot handle the amount of data I am asking to paste.<o:p></o:p>
<o:p></o:p>
I would like to rewrite the code so it does one column at a time and five columns at a time. I am thing a loop might be the solution.<o:p></o:p>
<o:p></o:p>
I have pasted the code below. lngLastRow is variable that changes a lot. I don't think it handle being greater than 650. The columns are currently between B and BF.<o:p></o:p>
<o:p></o:p>
Dim lngLastRow As Long<o:p></o:p>
lngLastRow = Sheets("#Sheetnames2").Cells(Rows.Count, "C").End(xlUp).Row<o:p></o:p>
<o:p> </o:p>
Sheets("#Deal Banding Structure (1)").Range("B2:BF2").Copy _<o:p></o:p>
Destination:=Sheets("#Deal Banding Structure (1)").Range("B2:BF" & lngLastRow)<o:p></o:p>
<o:p></o:p>
If anybody has any solutions, that would be much appreciated.<o:p></o:p>
<o:p> </o:p>
Thanks a lot,<o:p></o:p>
<o:p></o:p>
Shivam
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Based on the code below, try:
Code:
Dim lngLastRow as Long
lngLastRow = Sheets("#Sheetnames2").Range("C" & Rows.Count).End(xlUp).Row
With Sheets("#Deal Banding Structure(1)")
  .Range("B2:BF" & lngLastRow).FillDown
End With
 
Upvote 0
Thanks for your suggestion. Much appreciated.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
<o:p></o:p>
However, I get a Run-time error '9':<o:p></o:p>
<o:p></o:p>
Subscript out of range.<o:p></o:p>
<o:p></o:p>
The line that starts with "with" is highlighted in yellow.<o:p></o:p>
<o:p></o:p>
Any suggestions?<o:p></o:p>
<o:p></o:p>
Thanks,<o:p></o:p>
<o:p></o:p>
Shivam<o:p></o:p>
 
Upvote 0

Forum statistics

Threads
1,224,584
Messages
6,179,693
Members
452,938
Latest member
babeneker

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