Public b As Integer
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
If Target.Column < 4 Or Target.Column > 12 Then Exit Sub
If b > 0 Then Exit Sub
a = Target.Row: b = Target.Column + 1
Cells(a, b) = Now
End Sub
代码写在工作簿ThisWorkbook模块中,这个代码不管你在哪个工作表修改数据都会产生效果,希望能帮助你
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
If Target.Column > 4 And Target.Column < 12 And Target.Column Mod 2 = 1 Then Target.Offset(, 1) = Now
End Sub
写到thisworkbook
如果你用
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column > 4 And Target.Column < 12 And Target.Column Mod 2 = 1 Then Target.Offset(, 1) = Now
End Sub
只能在代码当前sheet中发生事件
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 5 Or Target.Column = 7 Or Target.Column = 9 Or Target.Column = 11 Then
Target.Offset(, 1) = Now
End If
End Sub