Workbook_SheetChange event not working

smittymj

New Member
Joined
Jun 12, 2018
Messages
23
Hi, I'm trying to make this code work. It's supposed to change the values in all specific cells of certain sheets based on changes on a specific cell on any sheet. (e.g. If I change G2 of Sheet "Sensitivity", it should change D2 of certain sheets, and G2 of the rest"

Here's the code:

Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)

If Target.Address = "G2" Then
If Sh.Name = "AFS" Or Sh.Name = "IFS" Or Sh.Name = "Sales" Or Sh.Name = "Lease" Or Sh.Name = "Property" Or Sh.Name = "ProjectOuts" Or Sh.Name = "TrustOuts" Or Sh.Name = "Financing" Or Sh.Name = "Investors" Or Sh.Name = "Data" Then
   Application.EnableEvents = False
    Worksheets("Sensitivity").Range("D2:D2") = Target.Value
    Worksheets("Inputs").Range("D2:D2") = Target.Value
    Worksheets("Timing").Range("D2:D2") = Target.Value
    Worksheets("AFS").Range("G2:G2") = Target.Value
    Worksheets("IFS").Range("G2:G2") = Target.Value
    Worksheets("Sales").Range("G2:G2") = Target.Value
    Worksheets("Lease").Range("G2:G2") = Target.Value
    Worksheets("Property").Range("G2:G2") = Target.Value
    Worksheets("ProjectOuts").Range("G2:G2") = Target.Value
    Worksheets("TrustOuts").Range("G2:G2") = Target.Value
    Worksheets("Financing").Range("G2:G2") = Target.Value
    Worksheets("Investors").Range("G2:G2") = Target.Value
    Worksheets("GST").Range("G2:G2") = Target.Value
    Worksheets("Data").Range("G2:G2") = Target.Value
   Application.EnableEvents = True
  End If
 End If

End Sub

Hoping for any help. Thank you!
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
You've told us what it's meant to do, but not what it is doing?
 
Upvote 0
Ok, you need to make this change
VBA Code:
If Target.Address = "$G$2" Then
 
Upvote 0
Ok, you need to make this change
VBA Code:
If Target.Address = "$G$2" Then
Hi, thank you for helping. Though it still doesn't seem to be working. Still no changes/errors messages (It's macro-enabled and my other macros work fine).
 
Upvote 0
Where is the code located?
 
Upvote 0
Where is the code located?
Hi, I placed it in a module (which may be wrong?). Here's a screenshot:

1617896093920.png
 
Upvote 0
That's the wrong place, it needs to go in the ThisWorkbook module
 
Upvote 0
Solution

Forum statistics

Threads
1,215,206
Messages
6,123,639
Members
449,111
Latest member
ghennedy

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