The below code is supposed to track just the deletion of rows and columns. I want it to track the insertion of any new cells when i get the deletion part working correctly. The problem is with this code that dosnt matter if i insert or delete a cell or a column it treats it the same. Can anyone tell me whats wrong with my code?? How can i get it to only work deletion??? Then when that works how do I get it to track the insertion of a new row or collumn as well:
Code:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim What As String
If Target.Columns.Count = Columns.Count Then
What = "Row " & Target.Row & " Deleted along with " & Target.Rows.Count - 1 & " additonal rows"
Call DocumentChange(What)
End If
If Target.Rows.Count = Rows.Count Then
What = "Column " & Target.Column & " Deleted along with " & Target.Columns.Count - 1 & " additonal columns"
Call DocumentChange(What)
End If
End Sub
module:
Sub DocumentChange(What As String)
Dim r As Long
r = Sheet2.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
Sheet2.Cells(r, 1) = What
Sheet2.Cells(r, 2) = Now
Sheet2.Cells(r, 3) = Environ("username")
End Sub