Error 438 when copy and paste

123excel

New Member
Joined
Jan 18, 2017
Messages
34
Hi, I have the following code. What it does is that it automatically adds a new row when some conditions are fullfilled. This works good, but I am having problem with the next step, which is to copy and paste the value in "D35" To the new created row in column "AB".

As you can see below, after I added a new row I have the following code:
Range("D35").Copy .Cells(R, Col).Offset(1, 2).Paste

But this gives me error 438: "Object Doesn't Support This Property or Method". Anyone have a solution for this?



Code:
Sub Addrows()


    Dim Col As Variant
    Dim BlankRows As Long
    Dim LastRow As Long
    Dim R As Long
    Dim StartRow As Long


        Col = "Z"
        StartRow = 1
        BlankRows = 1


            LastRow = Cells(Rows.Count, Col).End(xlUp).Row


            Application.ScreenUpdating = False


            With ActiveSheet
For R = LastRow To StartRow + 1 Step -1
If .Cells(R, Col) = Range("D35") And .Cells(R, Col).Offset(0, 2) <> "" And .Cells(R, Col).Offset(1, 0) = "" Then
.Cells(R + 1, Col).EntireRow.Insert Shift:=xlDown


Range("D35").Copy .Cells(R, Col).Offset(1, 2).Paste




End If
Next R
End With
Application.ScreenUpdating = True


End Sub
 
Last edited:

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Use
Code:
Range("D35").Copy .Cells(R, Col).Offset(1, 2)
 
Upvote 0
Seriously! It was that easy.. I have been fighting this error for two hours.

Thanks a lot for your help! Worked perfect
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0
Use
Code:
Range("D35").Copy .Cells(R, Col).Offset(1, 2)

Hmm, this created another issue thought.. I only want to paste the value. How can I do this? Normally I would use PasteSpecial but because we do not use .paste, how can I achieve that?
 
Upvote 0
Like
Code:
.Cells(r, Col).Offset(1, 2).Value = Range("D35").Value
 
Upvote 0

Forum statistics

Threads
1,223,904
Messages
6,175,295
Members
452,631
Latest member
a_potato

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