Creating a LOG

AbuFawaz

New Member
Joined
Sep 21, 2017
Messages
9
I have this code that records the change, its date and the user that did it for all sheets on another sheet, what i need is only the changes in column "N" in a sheet named "Input" to be recorded, below is the code:

Private Sub Workbook_Open()
Sheets("LogDetails").Visible = True
End Sub


Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
If ActiveSheet.Name <> "LogDetails" Then
Application.EnableEvents = False
Sheets("LogDetails").Range("A" & Rows.Count).End(xlUp).Offset(1, 0).Value = ActiveSheet.Name & " - " & Target.Address(0, 0) & " " & Target.Value
Sheets("LogDetails").Range("A" & Rows.Count).End(xlUp).Offset(0, 1).Value = ""
Sheets("LogDetails").Range("A" & Rows.Count).End(xlUp).Offset(0, 2).Value = Environ("username")
Sheets("LogDetails").Range("A" & Rows.Count).End(xlUp).Offset(0, 3).Value = Now
Sheets("LogDetails").Columns("A:D").AutoFit
Application.EnableEvents = True
End If
End Sub



This is my first question on this form I hope I can get some help,

Many thanks in advance.
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Hi, welcome to the forum!

Try removing the Workbook_SheetChange event code that you have from the "Thisworkbook" code module and instead add the below code to the "Input" sheet code module.


Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim r As Range, c As Range
Set r = Intersect(Target, Columns("N"))
If Not r Is Nothing Then
    For Each c In r
        With Sheets("LogDetails").Range("A" & Rows.Count).End(xlUp)
            .Offset(1, 0).Value = c.Address & " " & c.Value
            .Offset(1, 1).Value = ""
            .Offset(1, 2).Value = Environ("username")
            .Offset(1, 3).Value = Now
        End With
    Next c
    Sheets("LogDetails").Columns("A:D").AutoFit
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,200
Members
453,022
Latest member
RobertV1609

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