View Single Post
 
Old 04-16-2020, 12:02 PM
emsa emsa is offline Windows 7 64bit Office 2010 64bit
Novice
 
Join Date: Sep 2013
Posts: 4
emsa is on a distinguished road
Default Event macro: insert row with formulae based on current row, clear selected contents

Good afternoon all,

I'm failing miserably to get the below macro to leave the data in the first two columns when a new row is inserted and the cell contents are cleared. Is there a line I can insert that basically says clear everything but leave the values that were in columns A and B.


Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
   Cancel = True   'Eliminate Edit status due to doubleclick
     Target.Offset(1).EntireRow.Insert
     Target.EntireRow.Copy Target.Offset(1).EntireRow
        On Error Resume Next
     Target.Offset(1).EntireRow.SpecialCells(xlConstants).ClearContents
   On Error GoTo 0
End Sub
Can this line be modified somehow...

Code:
Target.Offset(1).EntireRow.SpecialCells(xlConstants).ClearContents


Any help would be greatly appreciated.


Regards,


Emsa
Reply With Quote