Data validation updates

jqfranco

New Member
Joined
Dec 27, 2017
Messages
28
I have an Excel file with two worksheets.


In the "ListSource" spreadsheet on lines A2; A150, I have the list that will feed the droplist.


In the "DropList" worksheet I have a droplist on the lines F3: F503.


When I change a value in my list in "ListSource", this change is reflected in the spreadsheet "DropList", in all cells that had the old value, which is correct.


The problem is that when I add a value in the list in "ListSource", in the "DropList" worksheet, in all droplist cells that are missing values, it adds the new value.


For example, if your I have cells written between the lines F3: F20, it puts the new value in the cells between F21 and F503, without having done anything at all.


The code is placed in the Worksheet ListSource Change

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 - 3
    Set rng = Worksheets ("DropList") Range ("F4: F503")
    If Intersect (Target, Range ("A" & count_cells + 3)) 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
        Target.Select
    End If
Next count_cells
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub



If someone can help me solve this problem, thank you in advance.


Happy New Year 2018 for all of you
 
Last edited by a moderator:

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

Forum statistics

Threads
1,214,918
Messages
6,122,255
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top