Hello,
after googling for 2 days and trying to figure it out myself and failing, i came here to ask for some help.
I have mulitple sheets with ranges in it containing values selected from a drop down list.
Worksheets("Part Database").Range("C3:C10") <-range contains values selected from DropDownList
Worksheets("APM2").Range("D5: D11") <-range contains values selected from DropDownList
Worksheets("APM3").Range("K8:K15") <-range contains values selected from DropDownList
Worksheets("Input").Range("I2:I7") <- this sheet range contains the DropDown list source, I1 is the header of the list, the code also pasted on this sheet.
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("I1").CurrentRegion.Rows.Count - 1
Set rng = Worksheets("Part Database").Range("C3:C10")
If Intersect(Target, Range("I" & 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
Target.Select
End If
Next count_cells
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
The following code updates the ALREADY selected values from the DropDown on the Part Database sheet, if i change the source of the DropDownList on sheet "Input". It works just fine.
But i want to add more two more sheet range to the code to work:
Worksheets("APM2").Range("D5: D11")
Worksheets("APM3").Range("K8:K15")
The question is, how do i implement it to the code, so it not only updates the Part Database sheet C3:C10 range, but the two more ranges on APM2 and APM3 sheets?
I have created an example workbook to make it easier to understand:
https://ufile.io/p2zfn
after googling for 2 days and trying to figure it out myself and failing, i came here to ask for some help.
I have mulitple sheets with ranges in it containing values selected from a drop down list.
Worksheets("Part Database").Range("C3:C10") <-range contains values selected from DropDownList
Worksheets("APM2").Range("D5: D11") <-range contains values selected from DropDownList
Worksheets("APM3").Range("K8:K15") <-range contains values selected from DropDownList
Worksheets("Input").Range("I2:I7") <- this sheet range contains the DropDown list source, I1 is the header of the list, the code also pasted on this sheet.
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("I1").CurrentRegion.Rows.Count - 1
Set rng = Worksheets("Part Database").Range("C3:C10")
If Intersect(Target, Range("I" & 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
Target.Select
End If
Next count_cells
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
The following code updates the ALREADY selected values from the DropDown on the Part Database sheet, if i change the source of the DropDownList on sheet "Input". It works just fine.
But i want to add more two more sheet range to the code to work:
Worksheets("APM2").Range("D5: D11")
Worksheets("APM3").Range("K8:K15")
The question is, how do i implement it to the code, so it not only updates the Part Database sheet C3:C10 range, but the two more ranges on APM2 and APM3 sheets?
I have created an example workbook to make it easier to understand:
https://ufile.io/p2zfn