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
LVL 48

Accepted Solution

Rgonzo1971 earned 500 total points
Comment Utility

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

Comment Utility

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

All the best,


Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

728 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now