Important!
This needs to be pasted into Sheet1
object. You can get there by right-clicking the Sheet1
tab > View Code.
Also, I have done only minimal testing. Please let me know if this works for you.
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Debug.Print Now; " >> ws1 Value Chg'd @ "; Target.Address
Dim ws As Worksheet, iSectAY As Range, iSectDB As Range
Dim RngAY As Range, RngDB As Range
Dim RngAR As Range, RngCU As Range
Set ws = ThisWorkbook.Worksheets(1)
Set RngAR = ws.Range("AR67")
Set RngCU = ws.Range("CU67")
Set RngAY = ws.Range("AY:AY")
Set RngDB = ws.Range("DB:DB")
'Determine if the cell changed is a target cell
Set iSectAY = Intersect(Target, RngAY)
Set iSectDB = Intersect(Target, RngDB)
Dim iRow As Integer
If Not iSectAY Is Nothing Then
iRow = 1
If RngCU = "" Then
Application.EnableEvents = False
RngCU = 0
Application.EnableEvents = True
End If
ElseIf Not iSectDB Is Nothing Then
iRow = 2
If RngAR = "" Then
Application.EnableEvents = False
RngAR = 0
Application.EnableEvents = True
End If
Else
Exit Sub 'Cell updated was not the target
End If
'Set Sheet2's objects
Dim ws2 As Worksheet, UpdateRng1 As Range, UpdateRng2 As Range, iCol As Long
Set ws2 = ThisWorkbook.Worksheets(2)
iCol = ws2.Cells(iRow, Columns.Count).End(xlToLeft).Column + 1
Set UpdateRng1 = ws2.Cells(1, iCol)
Set UpdateRng2 = ws2.Cells(2, iCol)
UpdateRng1 = RngAR.Value
UpdateRng2 = RngCU.Value
End Sub