Below is my current code that is working fine. The Macro runs when I type a value into cell G2, it then adds the value of G2 to cell G4, G5, G6, G7, or G8 depending on the date. What code can I add to this so that once the macro adds G2 to the other cell, it would then delete the contents of cell G2?
Private Sub Worksheet_Change(ByVal Target As Range)
Dim nRw As Long, rCell As Range
Set rCell = Range("A1")
'My CODE FOR G ________________________________________________
If Target.Address = "$G$2" Then
If rCell.Value = "" Then
MsgBox "No Value Found", vbInformation, "Input Required"
Exit Sub
End If
On Error GoTo NoMatchFound:
nRw = Range("A:A").Find(rCell.Value).Row
With Cells(nRw, "G")
.Value = .Value + Range("G2").Value
End With
Exit Sub
'My CODE FOR H ________________________________________________
ElseIf Target.Address = "$H$2" Then
If rCell.Value = "" Then
MsgBox "No Value Found", vbInformation, "Input Required"
Exit Sub
End If
On Error GoTo NoMatchFound:
nRw = Range("A:A").Find(rCell.Value).Row
With Cells(nRw, "H")
.Value = .Value + Range("H2").Value
End With
Exit Sub
'My CODE FOR I ________________________________________________
ElseIf Target.Address = "$I$2" Then
If rCell.Value = "" Then
MsgBox "No Value Found", vbInformation, "Input Required"
Exit Sub
End If
On Error GoTo NoMatchFound:
nRw = Range("A:A").Find(rCell.Value).Row
With Cells(nRw, "I")
.Value = .Value + Range("I2").Value
End With
Exit Sub
NoMatchFound:
MsgBox "No Match Found", vbCritical, "Task Un-Successfull"
End If
End Sub
Bookmarks