Hi,
I want to copy current row and insert below.
Only formulas (and eventually formatting) should be copied.
It works fine but the problem is that values are copied too.
My code is
Public Sub insertRowBelow()
ActiveCell.Offset(1).EntireRow.Insert shift:=xlDown, CopyOrigin:=xlFormatFromRightOrAbove
ActiveCell.EntireRow.Copy
ActiveCell.Offset(1).EntireRow.PasteSpecial xlPasteFormulasAndNumberFormats
Application.CutCopyMode = False
End Sub
I found another thread from 2007 with similar problem but that code is completely different and I don't know how to combine these two codes.
Part of the solution (if you don't want to read the conversation) was to add:
If Target.Row = lastrow2 Then
Rows(lastrow2 - 1).Copy
Rows(lastrow2).Insert
On Error Resume Next
Rows(lastrow2).SpecialCells(xlCellTypeConstants).ClearContents
On Error GoTo 0
Application.CutCopyMode = False
End If
Can anyone please help me to extend the code to remove values and only keep the formulas?
Bookmarks