VBA - paste special "error 1004"

VBA

New Member
Joined
Jan 19, 2009
Messages
39
Heya,

I'm trying to incoperate "paste special" in my VBA-code and used "macro recorder" to figure out how to do so. However, when I try to run the so developed code it gives an error :eek: I have no clue why :confused:

CODE:
Sub Ooops()
Sheets("JD").Visible = False
Sheets("Jn").Delete
Sheets("JD").Range("A1:Z480").Copy
Sheets.Add.Name = "Jn"
Sheets("Jn").Range("A10").Select
ActiveSheet.PasteSpecial Paste:=xlPasteValues, _
Operation:=xlNone, _
SkipBlanks:=False, _
Transpose:=False
End Sub

Anybody who can tell me what I'm doing wrong? I can't use "paste" as then I'll get the wrong values...

Thanks in advance :cool:
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Hi & welcome to the board,

Try:

Code:
Sub Ooops()
Sheets("JD").Visible = False
Sheets("Jn").Delete
Sheets("JD").Range("A1:Z480").Copy
Sheets.Add.Name = "Jn"
Sheets("Jn").Range("A10").PasteSpecial Paste:=xlPasteValues, _
Operation:=xlNone, _
SkipBlanks:=False, _
Transpose:=False
End Sub

Dom
 
Upvote 0
:biggrin: It works

Not that I really understand why :rolleyes: I mean, it should be the same... Right?

Ow well, I guess VBA will always stay a bit mysterious :p Somehow it never quite does what I expect :ROFLMAO:

Thanks a lot!
 
Upvote 0
If you have a look at the VBA help it explains the different approaches. The one you were using is applicable to Excel's worksheet object and is for when you want to paste data from another application into Excel however you needed it to be used as applicable to the Range object where you must specify the specific destination range as part of the pastespecial operation.

Dom
 
Upvote 0

Forum statistics

Threads
1,216,744
Messages
6,132,470
Members
449,729
Latest member
davelevnt

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