copypaste problem

ndendrinos

Well-known Member
Joined
Jan 17, 2003
Messages
1,694
this works
Code:
Sheets("Records").Range("columns").Copy Destination:=Sheets("Statement").Range("A1")

but when I change the range to

Code:
Sheets("Records").Range("columns").Copy Destination:=Sheets("Statement").Range("A5")

it does not ...(copy area paste area not the same...)

There are no merged cells copied ... so what is the problem?
Thanks
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
thanks,
all rows in columns
BTW would prefer to make it "dynamic"
Code:
=Records!$A:$A,Records!$B:$B,Records!$C:$C,Records!$E:$E,Records!$FS:$FS
 
Upvote 0
You are copying whole columns which is every row in each column. This works when copying to Row 1, but when you try to copy to Row 5, you run out of rows at the bottom of you worksheet!!! So, to make it dynamic, you need to copy only used rows. For us to avoid guessing, can you explain EXACTLY what you are doing
??
lenze
 
Upvote 0
thanks njimack I will look at the link
lenze:
This is to generate a statement for any given customer:
I import all records from sheet records (each rows = one invoice) then I filter by dates (from/to) and by customer name.
I've been doing this all along by importing all columns then deleting most to end up with just the 5
 
Upvote 0
Could solve it like this (deducted 5rows from copied range) but (again) would prefer a dynamic range
Code:
=Sheet1!$A$1:$A$65531,Sheet1!$C$1:$C$65531,Sheet1!$O$1:$O$65531
 
Upvote 0
This can easily be done by finding the last row and only copying used range , but I don't have a handle as to what you want copied and where. If you are importing All records and then filtering to only certain oned by customer?) , why not just import the ones for that customer?? You can use Advanced Filter or MSQuery!!
lenze
 
Upvote 0
thanks Lenze,
What you are suggesting I do on sheet2 instead of sheet1
As to the "dynamic" range I don't see any benefit to it anymore since (in theory) if I fill Sheet1 with 65536 rows and tried to paste to sheet2 starting in A5 the code would fail for the reason you've explained.
Since at most (per year @ 10 measly invoices a day) I'll have just 3650 rows filled in sheet1 I don't foresee a problem.
Would have been nice to learn how to create a dynamic named range.
Checked @ contextures and as usual ended up unable to apply Debra's solution to my needs.
 
Upvote 0
If you are copying using vba why not set the range to be just the used portion of the column, like this
Code:
Dim MyRange As Range
Set MyRange = Range("A1:A" & Range("A" & Rows.Count).end(xlup).row)
 
Upvote 0

Forum statistics

Threads
1,224,591
Messages
6,179,767
Members
452,940
Latest member
rootytrip

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