• Worksheet changes (XL 2000 SP3)

    Author
    Topic
    #447499

    I have my UsageLog This Thread working for file opened, file saved, and username, but I cannot get it to record when changes are made anywhere in the workbook.

    I tried:

    Private Sub Worksheet_Change(ByVal Target As Excel.Range)

    ActiveWorkbook.Worksheets(“UsageLog”).Range(“A65536”).End(xlUp).Offset(0, 1).Value = Time$ & Space(5) & Date$

    End Sub

    saved in ThisWorkbook, without success, so I tried the simpler:

    Private Sub Worksheet_Change(ByVal Target As Excel.Range)

    MsgBox “Range ” & Target.Address & “was changed”

    End Sub

    Taken from John Walkenbach, but again no success. Can anyone help please?

    Viewing 1 reply thread
    Author
    Replies
    • #1091541

      The Worksheet_Change event procedure should *not* go into ThisWorkbook, but – as the name indicates – into the worksheet module for each worksheet.

      • #1091546

        Is there anything wrong in altering it to look like this:

        Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
        ActiveWorkbook.Worksheets(“UsageLog”).Range(“A65536”).End(xlUp).Offset(0, 1).Value = Time$ & Space(5) & Date$
        End Sub

        This will work across all sheets now.

    • #1091684

      Thanks Hans and Rudi

      Having to put the code in each sheet would be a bit of a drag, but Rudi’s code works beautifully.

      Will someone explain to me what the (ByVal Sh As Object, ByVal Target As Range) does?

      • #1091689

        When the worksheet change event fires, Excel passes the sheet that was changed and the cell or cells that were changed in those two parameters. Otherwise, the code would only know that one or more cells somewhere in the workbook had changed.

    Viewing 1 reply thread
    Reply To: Worksheet changes (XL 2000 SP3)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: