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?
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: