.PasteSpecial Issues Using External Workbooks

tjiddy89

New Member
Joined
Mar 7, 2018
Messages
20
I'm trying to generate a script that locates the last row with a value contained within it and store it in a variable. I then use said variable in a range and then copy the data from an external (closed) workbook. I am able to see that it copies the data correctly, however when it gets down to the pastespecial function I run into a 1004 runtime "Application-defined or object-defined error".

Thank you in advance for your assistance.

Code:
lRow = Workbooks(qc).Sheets(2).Cells.Find(What:="*", _  After:=Range("A1"), _
  LookAt:=xlPart, _
  LookIn:=xlFormulas, _
  SearchOrder:=xlByRows, _
  SearchDirection:=xlPrevious, _
  MatchCase:=False).row

'Tried the below method as well to no success.

'Workbooks(dest).Sheets(2).Range(Workbooks(dest).Sheets(2).Cells(2, 2), Workbooks(dest).Sheets(2).Cells(lRow, 34)).Value = Workbooks(qc).Sheets(2).Range(Workbooks(qc).Sheets(2).Cells(1, 1), Workbooks(qc).Sheets(2).Cells(lRow, 33)).SpecialCells(xlCellTypeVisible)
    
'This is because the destination sheet's cells will be in a different area.
lRow = lRow + 2

'Below is where I'm getting the 1004 error.  More specifically the Workbook(dest) line.
Workbooks(qc).Sheets(2).Cells.SpecialCells(xlCellTypeVisible).Copy
Workbooks(dest).Worksheets(2).Range("B3:" & Workbooks(dest).Worksheets(2).Cells(lRow, 33)).PasteSpecial xlPasteValues
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Try
Code:
Workbooks(dest).Worksheets(2).Range("B3").PasteSpecial xlPasteValues
 
Upvote 0
Do you have any merged cells, or sheet protection?
 
Upvote 0
Change of plan, try
Code:
Workbooks(dest).Worksheets(2).Range("[COLOR=#ff0000]A[/COLOR]3").PasteSpecial xlPasteValues
 
Upvote 0
You're copying the entire row, therefore you have to paste into col A.
 
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,964
Members
452,371
Latest member
Frana

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