runtime error 1004 pastespecial method of range class failed

forginganewone

Board Regular
Joined
Mar 14, 2018
Messages
64
I keep getting this error "runtime error 1004 pastespecial method of range class failed" on following code :

Option Explicit

Sub copypasterow()
'
' chequerecieving Macro
' copy active row to another workbooks last row
'
' Keyboard Shortcut: Ctrl+l
'
Dim wbTarget As Workbook
Selection.EntireRow.Copy
Set wbTarget = Workbooks.Open("D:\Office\Rental Cheques\Recieving\Recieving File 1\Recieving file 1.xlsx")
wbTarget.Sheets("Sheet1").Range("C1").End(xlDown).Offset(1, 0).PasteSpecial
Application.CutCopyMode = False

End Sub



Please help :(
 
I suppose you could have a shape or something selected which would produce an error but that would be an obvious mistake. But you need to do something like:

Code:
wbTarget.Sheets("Sheet1").Range("C" & Rows.Count).End(xlUp).Offset(1, -2).PasteSpecial xlPasteValues

Same error sir

I have tried the below totally different code aswell but it gives the same error.. its blowing my mind :

Option Explicit
Sub copypasterow()
'
' chequerecieving Macro
' copy active row to another workbooks last row
'
' Keyboard Shortcut: Ctrl+l
'

Dim wbTarget As Workbook
Dim Filetarget As String
Dim WorksheetEndRow As Integer


Filetarget = "D:\Office\Rental Cheques\Recieving\Recieving File 1\Recieving file 1.xlsx"


Selection.EntireRow.Copy
Set wbTarget = Workbooks.Open(Filetarget)
WorksheetEndRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
Range("A" & WorksheetEndRow + 1).PasteSpecial
Application.CutCopyMode = False

End Sub
 
Upvote 0

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Steve, your right, not sure what I was thinking...unless of course the desired cell had not been previously selected
 
Upvote 0
Same error sir

I have tried the below totally different code aswell but it gives the same error.. its blowing my mind :

Option Explicit
Sub copypasterow()
'
' chequerecieving Macro
' copy active row to another workbooks last row
'
' Keyboard Shortcut: Ctrl+l
'

Dim wbTarget As Workbook
Dim Filetarget As String
Dim WorksheetEndRow As Integer


Filetarget = "D:\Office\Rental Cheques\Recieving\Recieving File 1\Recieving file 1.xlsx"


Selection.EntireRow.Copy
Set wbTarget = Workbooks.Open(Filetarget)
WorksheetEndRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
Range("A" & WorksheetEndRow + 1).PasteSpecial
Application.CutCopyMode = False

End Sub

You have missed out the sheet name now from the target workbook. What does WorksheetEndRow equal? Put a message box in there to find its value once its been assigned one.
 
Upvote 0
You have missed out the sheet name now from the target workbook. What does WorksheetEndRow equal? Put a message box in there to find its value once its been assigned one.

I think the previous code i posted orinignally should work, please help fix that. If you can amend that code and fix errors and paste it again .. i will be really helpful.
 
Upvote 0
Try replacing your paste special line from the original formula with my paste special line from post number 8. If that doesnt work. Do the steps manually. Are you able to paste? ie is the paste special greyed out.
 
Upvote 0

Forum statistics

Threads
1,223,909
Messages
6,175,310
Members
452,634
Latest member
cpostell

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