Dear all,
Good day!
I am trying to write vba code for copying a relative formula in a cell if formula in that cell is deleted by mistake.
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("c14:c1014")) Is Nothing And Target.Count = 1 Then
Application.EnableEvents = False
If IsEmpty(Target) Then
Target.Formula = Target.Offset(r - 1, c).Formula
End If
Application.EnableEvents = True
End If
End Sub
Thank you.
Can anyone help to correct the code as it is not copying the relative formula from one cell down of the cell, where formula is to be copied.
e.g
A B c
14 Formula
15 Copy here relative formula
16 Formula
.
.
1014
Good day!
I am trying to write vba code for copying a relative formula in a cell if formula in that cell is deleted by mistake.
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("c14:c1014")) Is Nothing And Target.Count = 1 Then
Application.EnableEvents = False
If IsEmpty(Target) Then
Target.Formula = Target.Offset(r - 1, c).Formula
End If
Application.EnableEvents = True
End If
End Sub
Thank you.
Can anyone help to correct the code as it is not copying the relative formula from one cell down of the cell, where formula is to be copied.
e.g
A B c
14 Formula
15 Copy here relative formula
16 Formula
.
.
1014