VBA .Paste Methods

Captain_Conman

Board Regular
Joined
Jun 14, 2018
Messages
54
Frequently when I write code such as the following...

Code:
Sheets("Sheet2").Range("A2").Paste

I get runtime error 438 "object doesn't support this property or method"

I usually just change it to .PasteSpecial or try another way of pasting and work it out. However, I have never understood why this happens.

Could someone give me some clarification on .Paste methods? What am I not understanding?

Full code if needed...

Code:
Sub Macro1()


Dim c As Range


For Each c In Range("A:A")
If c.Text = c.Offset(1, 0).Text Then
    If c.Offset(0, 2).Value = c.Offset(1, 2).Value * -1 Then
    Rows(c.Row & ":" & c.Row + 1).Cut
        If Sheets("Sheet2").Range("A2") = "" Then
        Sheets("Sheet2").Range("A2").Paste
    Else
        Sheets("Sheet2").Range("A1").End(xlDown).Offset(1, 0).Paste
        End If
    Else
    End If
    End If
    Next
    
End Sub
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Captain_Conman,

In the Excel Object Model, a Worksheet object supports both the .Paste and .PasteSpecial methods; a Range object only supports the .PasteSpecial method.

You could re-write the offending line of code to...

Code:
Sheets("Sheet2").Paste Destination:=Range("A2")

Cheers,

tonyyy
 
Upvote 0

Forum statistics

Threads
1,214,911
Messages
6,122,192
Members
449,072
Latest member
DW Draft

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