U_Shrestha
05-16-2008, 06:16 AM
Hi all,
I have the following code to enter data update date. Lately, this code works only when I first open the workbook and type something, after sometime, the code doesn't enter date, but when I close and reopen the file and enter something, then it works again. Can someone tell me what's needs to be changed. Is it because it is conflicting with other codes? Thanks.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rg As Range, rgRow As Range
On Error GoTo ExitHere
Set rg = Range("a1:b100")
If Intersect(rg, Target) Is Nothing Then Exit Sub
Application.EnableEvents = False
For Each rgRow In Intersect(Target, rg).Rows
Cells(rgRow.Row, "c") = Date
Next rgRow
ExitHere:
Application.EnableEvents = True
End Sub
I have the following code to enter data update date. Lately, this code works only when I first open the workbook and type something, after sometime, the code doesn't enter date, but when I close and reopen the file and enter something, then it works again. Can someone tell me what's needs to be changed. Is it because it is conflicting with other codes? Thanks.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rg As Range, rgRow As Range
On Error GoTo ExitHere
Set rg = Range("a1:b100")
If Intersect(rg, Target) Is Nothing Then Exit Sub
Application.EnableEvents = False
For Each rgRow In Intersect(Target, rg).Rows
Cells(rgRow.Row, "c") = Date
Next rgRow
ExitHere:
Application.EnableEvents = True
End Sub