VBA Code to update valiated data across multiple worksheets

Jan1419

New Member
Joined
Oct 12, 2017
Messages
2
Hi,

I'm very new to VBA code, was hoping for some help, I have the code below. This works perfectly in my spreadsheet with my data list on sheet 1 and my drop down lists on the sheet "Sep 17". I would like the code to work for additional sheets also, is there someone that can help me with this? Thank you in advance :)

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("B1").CurrentRegion.Rows.Count - 1
Set rng = Worksheets("Sep 17").Range("B7:AF235")
If Intersect(Target, Range("B" & 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
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
worksheet change has 2 params:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
you can use the incoming sh object

Set rng = sh.Range("B7:AF235")
 
Last edited:
Upvote 0
Thank you for your response, i tried copying
Set rng = sh.Range("B7:AF235")

instead of
Set rng = Worksheets("Sep 17").Range("B7:AF235")

but it didn't work... :(
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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