Thomas Kuriakose
Active Member
Respected Sirs,
We have multiple data validation cells and these are linked to multiple sources lists. The source is bound to change and hence we need the validated cell to reflect the change as soon as the list is changed.
I found a code to get the validation cell change automatically for one reference. Here the validated cell is C2 and the lists are in range G2 to G9.
We have similar validated cells in C3,C4,C5 and the corresponding lists in H2 to J9.
Kindly let me know how to get this working for multiple cells and lists.
Thank you very much,
with regards,
thomas
We have multiple data validation cells and these are linked to multiple sources lists. The source is bound to change and hence we need the validated cell to reflect the change as soon as the list is changed.
I found a code to get the validation cell change automatically for one reference. Here the validated cell is C2 and the lists are in range G2 to G9.
We have similar validated cells in C3,C4,C5 and the corresponding lists in H2 to J9.
Code:
Option Explicit
Private oldValue As String
Private Const DVCell As String = "C2"
Private Const dataList As String = "G2:g9"
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ws_exit:
Application.EnableEvents = False
If Target.Count = 1 Then
If Not Intersect(Target, Range(dataList)) Is Nothing Then
With Target
If Range(DVCell).Value = oldValue Then
Range(DVCell).Value = .Value
End If
End With
End If
End If
ws_exit:
Application.EnableEvents = True
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Count = 1 Then
If Not Intersect(Target, Range(dataList)) Is Nothing Then
If Not IsEmpty(Target) Then
oldValue = Target.Value
End If
End If
End If
End Sub
Kindly let me know how to get this working for multiple cells and lists.
Thank you very much,
with regards,
thomas