Offset Code

bschulze

Active Member
Joined
Jun 2, 2005
Messages
289
I have a piece of code that takes a copied range and pastes it into another worksheet using the offset property. This piece of code is not working and I think that is has something to do with the "Destination".


Dim PasteRng As Range
Set PasteRng = Sheets("Summary").Range("A65536").End(xlUp).Offset(1, 0)
Destination = PasteRng


Any help would be appreciated. Also let me know if there is a better way to write this. Thanks
 
bschulze.

are you copying from another worksheet (ie not summary?) you could try activating the summary sheet before. i always have problems with excel on this. something like

Code:
Worksheets("Summary").Activate
PasteRng.PasteSpecial xlPasteValuesAndNumberFormats

ben.
 
Upvote 0

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
I tried that I am still getting the same problem. The error is "Run-Time error 1004" "PasteSpecial method of range class failed"

I tried changing the code to:
PasteRng.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

But that did not work either.
 
Upvote 0
I just tried it again.

Dim PasteRng As Range
Set PasteRng = Sheets("Summary").Range("A65536").End(xlUp).Offset(1, 0)
Rows("1:1").Select
Selection.AutoFilter
Selection.AutoFilter Field:=2, Criteria1:=">0", Operator:=xlAnd
Range("A2:B2").Select
Range(Selection, Selection.End(xlDown)).Select
Worksheets("Summary").Activate
ActiveSheet.Paste


I got the same runtime error.
 
Upvote 0
OK I think I have it. There was not a code for the "Copy" function. I had this is the code above but not within the new code. Ok your original code works. Sorry for all the hasle. I forgot the .copy on the back end of the original code.

Thanks for you help
 
Upvote 0

Forum statistics

Threads
1,215,764
Messages
6,126,749
Members
449,335
Latest member
Tanne

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