Error 438 'Object does not support this property or method' When Pasting

MarsBars

New Member
Joined
May 21, 2014
Messages
27
Hello,

I'm having one of those days where I can't seem to see the minor error that is completely stopping my entire workflow. Whenever I run the following code, I get an "Object does not support this property or Method" on the "Template.Sheets(1).Range("A1").Paste" line at the bottom.

Code:
ScreenUpdating = False
Dim RawData As Workbook, Template As Workbook
Set RawData = ActiveWorkbook
Set Template = Workbooks("TEMPLATE for Samples Monthly Numbers .xlsm")
 
    Rows("1:2").Delete Shift:=x2Up
    Columns("D:D").Cut
    Columns("A:A").Insert Shift:=xlToRight
    Columns("B:B").TextToColumns Destination:=Range("B1"), DataType:=xlFixedWidth, _
        FieldInfo:=Array(Array(0, 3), Array(11, 9)), TrailingMinusNumbers:=True
    Columns("C:C").Select
    Selection.TextToColumns Destination:=Range("C1"), DataType:=xlFixedWidth, _
        FieldInfo:=Array(0, 3), TrailingMinusNumbers:=True
    Columns("D:D").Select
    Selection.TextToColumns Destination:=Range("D1"), DataType:=xlFixedWidth, _
        FieldInfo:=Array(0, 3), TrailingMinusNumbers:=True
    Columns("A:A").Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
    Range("A1").Value = "Unique PO ID"
    Range("B1").Copy
    Range("A1").PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
        SkipBlanks:=False, Transpose:=False
    Application.CutCopyMode = False
    
    
    'Loop to give each order line a unique PO ID
    Dim i As Integer
    i = 1
    
    Do Until Cells(1 + i, 2) = ""
        Cells(1 + i, 1).Value = i
        i = i + 1
    Loop
    
    Template.Worksheets("Paste Raw Data Here").UsedRange.Clear
    
    RawData.Sheets(1).UsedRange.Copy
    
    Template.Sheets(1).Range("A1").Paste
    

    Application.CutCopyMode = False
    Calculate
    
ScreenUpdating = True
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Try
Code:
RawData.Sheets(1).UsedRange.Copy Destination:=Template.Sheets(1).Range("A1")

(and omit the line that begins Template.Sh.......)
 
Upvote 0
Mike,

That did it. I know that the way I had it was inefficient, but I still don't understand why it wouldn't work. Would you be able to shed some light on that? It's okay if not. I'm just curious.

Either way, thanks for the help.
 
Upvote 0
.Paste is not a method of a Range object. (.PasteSpecial IS) .Paste is a method of a worksheet object.

You could try replacing the line in the OP code with
Code:
Template.Sheets(1).Paste

I prefer specifying the destination in the .Copy method , because the Worksheet.Paste method depends on the Selected cell on that sheet.
 
Upvote 0

Forum statistics

Threads
1,216,297
Messages
6,129,954
Members
449,544
Latest member
Akhil333

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