I have code that copies and inserts a new row into my audit worksheet when the row is deleted from the original worksheet. Now I want to insert three new bits of data at the end if the just pasted row. The fileds are; Date, Time, and application.user. All the code works but I cannot find the correct code to add the three new fields, Here is my code:
Private Sub cmdDeleteRow_Click()
Dim ws As Worksheet
Dim lRow As Long
Dim LastRow As Long
Dim rn As Range
Set rn = ActiveCell.EntireRow
Dim audit As Worksheet
Set audit = Worksheets("Audit")
If Not IsInRange(ActiveCell, ActiveSheet.Range("ForecastTable")) Then
MsgBox "You can not delete lines here.", vbCritical
Exit Sub
End If
Application.ScreenUpdating = False
ActiveSheet.Unprotect
' MsgBox "You are about to copy the deleted data to the Audit tab "
rn.Copy
Worksheets("Audit").Range("A" & (Worksheets("Audit").UsedRange.Rows.Count + 1)).PasteSpecial xlPasteValuesAndNumberFormats
rn.Delete
'
' Code to add date and time stamp and user id
Worksheets("Audit").Range(0, 77)).Value = Date
Worksheets("Audit").Range(0, 78).Value = Time
Worksheets("Audit").Range(0, 79).Value = Application.UserName
' End of code add date and time stamp and user id
ActiveSheet.Protect
Application.ScreenUpdating = True
End Sub