http://www.excelforum.com/excel-gene...reasheets.html
I have provided a working solution for the OP for an onClose event, but he is looking for an instantaneous change. I tried a similar solution for the Workbook_Sheet Change Event and the Worksheet Change Event (putting the VBA in all three sheets for the worksheet change event).
In all cases, the VBA just hangs. If I stop the VBA from running, it has updated the cells A1 and B1. If you have a solution for this, then please offer it up. For the record, here is what I tried in the worksheet change event for each of the sheets. Did I miss something to make it hang???
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" Then
Dim myDate As Date
myDate = Application.WorksheetFunction.Max(Sheets("Sheet1").Range("A1"), _
Sheets("Sheet2").Range("A1"), Sheets("Sheet3").Range("A1"))
Sheets("Sheet1").Range("A1") = myDate
Sheets("Sheet2").Range("A1") = myDate
Sheets("Sheet3").Range("A1") = myDate
Sheets("Sheet1").Range("B1") = Environ("UserName")
Sheets("Sheet2").Range("B1") = Environ("UserName")
Sheets("Sheet3").Range("B1") = Environ("UserName")
End If
End Sub
Bookmarks