Track changes in a certain column

SiRhOSEven

New Member
Joined
Jan 21, 2018
Messages
9
Hello, I have a worksheet that track changes and logs into a sheet when cell changes. It logs the Sheet Name where the change happen.

However, I have multiple data that needs to change in a single sheet. The problem is that it only logs the sheet name and not the column where I change the cell.

With this, I want to track changes in a certain column and returns a "text" where the changes happens instead of the sheet name. Below is the code that I got from searching google:

Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)If ActiveSheet.Name <> "LOGS" Then
Application.EnableEvents = False
 Dim OldValue As String, NewValue As String
        NewValue = Target.Value


        Application.Undo
        
        OldValue = Target.Value


        Target.Value = NewValue
    


Sheets("LOGS").Range("B" & Rows.Count).End(xlUp).Offset(1, 0).Value = ActiveSheet.Name
Sheets("LOGS").Range("B" & Rows.Count).End(xlUp).Offset(0, 1).Value = OldValue
Sheets("LOGS").Range("B" & Rows.Count).End(xlUp).Offset(0, 2).Value = NewValue
Sheets("LOGS").Range("B" & Rows.Count).End(xlUp).Offset(0, 3).Value = Date
Sheets("LOGS").Range("B" & Rows.Count).End(xlUp).Offset(0, 4).Value = Time
Sheets("LOGS").Range("B" & Rows.Count).End(xlUp).Offset(0, 5).Value = Date
Application.EnableEvents = True


End If
End Sub

Here is the link for the sample file for you to check => https://drive.google.com/file/d/1pxi9Ulr9Gb-5vrKgv8oYjOIRzKE0qhfW/view?usp=sharing


Thank you to all.
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Perhaps this:-
Code:
Sheets("LOGS").Range("B" & Rows.Count).End(xlUp).Offset(1, 0).Value = Target.Column
 
Upvote 0
Hi MickG, thank you for the reply but it will not work on my excel file. However, I come up with this one:

Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)If ActiveSheet.Name <> "LOGS" Then
Application.EnableEvents = False
 Dim OldValue As String, NewValue As String
        NewValue = Target.Value


        Application.Undo
        
        OldValue = Target.Value


        Target.Value = NewValue
    

If Target.Column = 3 Then
Sheets("LOGS").Range("B" & Rows.Count).End(xlUp).Offset(1, 0).Value = "The name that I want to output"
Sheets("LOGS").Range("B" & Rows.Count).End(xlUp).Offset(0, 1).Value = OldValue
Sheets("LOGS").Range("B" & Rows.Count).End(xlUp).Offset(0, 2).Value = NewValue
Sheets("LOGS").Range("B" & Rows.Count).End(xlUp).Offset(0, 3).Value = Date
Sheets("LOGS").Range("B" & Rows.Count).End(xlUp).Offset(0, 4).Value = Time
Sheets("LOGS").Range("B" & Rows.Count).End(xlUp).Offset(0, 5).Value = Date
End If

If Target.Column = 6 Then
Sheets("LOGS").Range("B" & Rows.Count).End(xlUp).Offset(1, 0).Value = "The name that I want to output"
Sheets("LOGS").Range("B" & Rows.Count).End(xlUp).Offset(0, 1).Value = OldValue
Sheets("LOGS").Range("B" & Rows.Count).End(xlUp).Offset(0, 2).Value = NewValue
Sheets("LOGS").Range("B" & Rows.Count).End(xlUp).Offset(0, 3).Value = Date
Sheets("LOGS").Range("B" & Rows.Count).End(xlUp).Offset(0, 4).Value = Time
Sheets("LOGS").Range("B" & Rows.Count).End(xlUp).Offset(0, 5).Value = Date
End If


Application.EnableEvents = True


End If
End Sub

And so on. :)
 
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,186
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top