VBA Copy/Paste Error

AlexB123

Board Regular
Joined
Dec 19, 2014
Messages
207
Hi all,

I have a macro that runs some calculations and then copies results to another file. However, I'm getting a 438 run-time error stating "Object doesn't support this property or method".

Code:
Set dbWB = Workbooks.Open(DBFile)
                Set dbSh1 = dbWB.Sheets("DB_Ready")
            DBlastrow = dbSh1.Rows.Range("A65000").End(xlUp).Row
           
      tmpSh2.Range("A2:I" & Templatelastrow).Copy
            
            dbSh1.Range("A" & DBlastrow + 1).Paste

I attempted to use:
Code:
dbSh1.PasteSpecial xlPasteAll
The above change allowed the sub to complete, but my results were pasted to the right of the current region.

Not sure what the issue is ... I feel like it has to do with adding the "+1", but I need the data to be pasted below the last used row.

Any help is appreciated!
 
Last edited:

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Try:
Rich (BB code):
Sub Mac1()

    Dim x   As Long
    Dim wkb As Workbook
    
    Set wkb = Workbooks.Open(dbfile)
    With wkb
        .Sheets("DB_Ready").Cells(Rows.Count, 1).End(xlUp).Offset(1).Resize(Templatelastrow, 9).Value = tmpsh2.Cells(2, 1).Resize(Templatelastrow, 9).Value
    End With
    Set wkb = Nothing
    
End Sub
 
Last edited:
Upvote 0
Try
Code:
tmpSh2.Range("A2:I" & Templatelastrow).Copy dbSh1.Range("A" & DBlastrow + 1)
 
Upvote 0
Fluff, JackDanIce,

Thank you both for your posts! I tested both solutions, and both solve my problem.

Any ideas as to why .paste would not work???
 
Upvote 0
.Paste is a worksheet method, whereas .PasteSpecial is a range method.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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