A może tak:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row >= 1 And Target.Row <= 10 And Target.Column = 2 Then
Target.Offset(0, -1) = Format(Date, "yyyy-mm-dd")
End If
End Sub
Pomyślałem jeszcze trochę i mam nową propozycję.
W poniższym makrze określasz zakres w którym ma działać dane makro.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim oRange As Range
Set oRange = Me.Range("B2:C10")
If Target.Row >= oRange.Cells(1).Row And Target.Row <= oRange.Cells(oRange.Cells.Count).Row _
And Target.Column >= oRange.Cells(1).Column And Target.Column <= oRange.Cells(oRange.Cells.Count).Column Then
Application.EnableEvents = False
Target.Offset(0, -1) = Format(Date, "yyyy-mm-dd")
Application.EnableEvents = True
End If
Set oRange = Nothing
End Sub |