RomulusMilea
Board Regular
- Joined
- May 11, 2002
- Messages
- 175
Hello All,
Below code works just fine. Section 1 adds in column A a timestamp, if something is written in column C (same row).
Section 2 does the opposite, i.e. if value in column C (in one cell, only) is deleted, then the value on the same row (one cell, only), but in column A is simple deleted, too. So far, so good .
The issue is that Section 2 works for one cell at the time, it does not work if I select 2 or more cells. What I need is an improvement of Section 2, I mean if I select any number of cells in column C (more than one cell) and I clear the values in selected cells, then the corresponding range in column A (same rows as selection in column C) to be cleared, as well.
Of course, the way improved section 2 should work must not change/cancel/interfere the job done by section 1.
Any idea, please ?
Below code works just fine. Section 1 adds in column A a timestamp, if something is written in column C (same row).
Section 2 does the opposite, i.e. if value in column C (in one cell, only) is deleted, then the value on the same row (one cell, only), but in column A is simple deleted, too. So far, so good .
The issue is that Section 2 works for one cell at the time, it does not work if I select 2 or more cells. What I need is an improvement of Section 2, I mean if I select any number of cells in column C (more than one cell) and I clear the values in selected cells, then the corresponding range in column A (same rows as selection in column C) to be cleared, as well.
Of course, the way improved section 2 should work must not change/cancel/interfere the job done by section 1.
Any idea, please ?
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo Handler
' Start of Section 1
If Target.Column = 3 And Target.Value <> "" Then
Application.EnableEvents = False
Target.Offset(0, -2) = Format(Now(), "d-mmm-yyyy h:mm")
Application.EnableEvents = True
End If
'End of Section 1
'Start of Section 2
If Target.Column = 3 And Target.Value = "" Then
Application.EnableEvents = False
Target.Offset(0, -2).ClearContents
Application.EnableEvents = True
End If
'End of Section 2
Handler:
End Sub