Hi All,
Does anyone know of VBA code which can distinguish whether a cell has been edited by:
selecting an option from a data validation list (DVL)
or
manually editing the text in a cell?
The "Show error alert after invalid data is entered" option is unticked to allow both selection from the DVL as well as free format text entries.
The problem arises when using the code below which makes an edited cell within a range display the new value as well as the prior value(s). This works well when using the DVL but not when editing the cell.
Is there any code which can distinguish between the 2?
Hope this makes sense, please let me know if anything requires further clarification.
Many thanks in advance
JLD
Public Prior As String
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
Application.EnableEvents = False
If Not Intersect(Target, Range("E3:E100")) Is Nothing Then
If Target <> "" Then
If Prior <> "" Then Target = Target.Text & Chr(10) & Prior
Prior = Target
Else
Prior = ""
End If
End If
Application.EnableEvents = True
End Sub
Does anyone know of VBA code which can distinguish whether a cell has been edited by:
selecting an option from a data validation list (DVL)
or
manually editing the text in a cell?
The "Show error alert after invalid data is entered" option is unticked to allow both selection from the DVL as well as free format text entries.
The problem arises when using the code below which makes an edited cell within a range display the new value as well as the prior value(s). This works well when using the DVL but not when editing the cell.
Is there any code which can distinguish between the 2?
Hope this makes sense, please let me know if anything requires further clarification.
Many thanks in advance
JLD
Public Prior As String
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
Application.EnableEvents = False
If Not Intersect(Target, Range("E3:E100")) Is Nothing Then
If Target <> "" Then
If Prior <> "" Then Target = Target.Text & Chr(10) & Prior
Prior = Target
Else
Prior = ""
End If
End If
Application.EnableEvents = True
End Sub