Update data validation list values automatically in multiple sheets when the source data changes

79 views Asked by At

I find a VBA code what looks good, and works fine, but just with one sheet.

I have 2 sheets. The first contain the validation source, and the second contains the data validation list.

When I change an existing value in the source, in the second sheet updated automatically.

My problem is that I have more sheets which contain data validation list with same validation source, but my VBA code works only one sheet. I don't know how I make it to wok with multiple sheets.

This is the current code:

Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
Dim count_cells As Integer
Dim new_value As String
Dim old_value As String
Dim rng As Range
For count_cells = 1 To Range("A1").CurrentRegion.Rows.Count - 1
    Set rng = Worksheets("Test1").Range("A:A")
    If Intersect(Target, Range("A" & count_cells + 1)) Is Nothing Then
    Else
        Application.EnableEvents = False
        new_value = Target.Value
        Application.Undo
        old_value = Target.Value
        Target.Value = new_value
        rng.Replace What:=old_value, Replacement:=new_value, LookAt:=xlWhole
        Target.Select
    End If
Next count_cells
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
0

There are 0 answers