Macro Firing Cell Change

Posted on 2012-12-24
Last Modified: 2012-12-24
EE Pros,

Happy holidays!  

I have a Macro that fires when a change is made to cell B1 (in WS2).  I have modified the Workbook so that I have a Worksheet that has the change I want to make to B1 on a different sheet (Sheet1, Cell D5).  When I input the text into cell D5, I want it to reflect the change in cell B1 and have the macro fire.  Unfortunately, as you may see with the code below, I have to reinter the same data into B1 (WS2).  In otherwords, I need the simple fix of how to reflect a change in Sheet1, Cell D5 into cell B1; then have the Macro fire.

That's it!

Thank you in advance,


Private Sub Worksheet_Change(ByVal Target As Range)
    On Error GoTo Err
    Dim rgWidth As Range, rgInitialize As Range, targ As Range
    Dim rng1 As Range, rng2 As Range
    Dim rng1LastRow As Long, rng2LastRow As Long
    Application.EnableEvents = False
    Application.ScreenUpdating = False

    'Watch this cell for changes
    Set targ = Range("B1")
    'Reinitialize these cells if the watched cell changes
    Set rgInitialize = Union(Range("A3:A50"), Range("C3:C50"))
    'Change the column width of these cells as data changes
    Set rgWidth = Union(Range("B3:B50"), Range("D3:D50"))
    If Intersect(targ, Target) Is Nothing Then Exit Sub
    rng1LastRow = Range("B" & Rows.Count).End(xlUp).Row
    rng2LastRow = Range("D" & Rows.Count).End(xlUp).Row
    Set rng1 = Range("B1:B" & rng1LastRow)
    Set rng2 = Range("D1:D" & rng2LastRow)
    If Not Intersect(Target, rng1) Is Nothing Then
        With Range("A" & Target.Row).Validation
            If Len(Trim(Target.Value)) <> 0 Then
                .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
                xlBetween, Formula1:="H,M,L"
            End If
        End With
    ElseIf Not Intersect(Target, rng2) Is Nothing Then
        With Range("C" & Target.Row).Validation
            If Len(Trim(Target.Value)) <> 0 Then
                .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
                xlBetween, Formula1:="H,M,L"
            End If
        End With
    End If
    Application.ScreenUpdating = True
    Application.EnableEvents = True
    Exit Sub
    MsgBox Err.Description
    GoTo Sidz
End Sub
Question by:Bright01
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 51

Accepted Solution

Rgonzo1971 earned 500 total points
ID: 38718063

With this code in sheet 1 , it will fire the code in sheet 2
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$D$5" Then
   Worksheets("Sheet2").Range("B1").Value = Target.Value
End If
End Sub

Open in new window


Author Closing Comment

ID: 38718331

Thank you!  Works perfectly.......... Have a great holiday.

All the best,


Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question