Subtract Updated Array w/ Stored Array Values

86 Views Asked by At

Script below currently stores an array and then compares it to an RTD updated array and outputs if there is a change. If there is no change then it will not log the change. Works great, but now I need an output log of the difference if a change occurs rather than output of a changed value in the updated array. enter image description here

Code in Module 1

 Public myArr()
 Public Sub 
 PopulateMyArr()
 myArr = Sheet4.Range("I6:I500").Value
 End Sub

Code in This Workbook

 Private Sub Workbook_Open()
 PopulateMyArr
 End Sub

Code in Sheet4(BA_Size)

 Private Sub ToggleButton1_Click()

 End Sub

 Private Sub Worksheet_Calculate()

 Dim keyCells As Range
 On Error GoTo safeexit
 Application.EnableEvents = False

 Set keyCells = Me.Range("I6:J500")

 If Worksheets("BA_Size").ToggleButton1.Value = True Then
 Dim i As Integer
 For i = 1 To UBound(myArr)
 If keyCells(i, 1).Value <> myArr(i, 1) Then
   
 nextrow = Sheet1.Cells(Sheet1.Rows.Count, "A").End(xlUp).Row + 1
 Sheet1.Cells(nextrow, "A").Value = Me.Cells(i + 5, "I").Value
 End If
 Next i
 
 End If
 safeexit:
 PopulateMyArr
 Application.EnableEvents = True
 End Sub
0

There are 0 best solutions below