Feb 25 2020 05:16 AM
I am trying to run a macro when a cell in a range of cells changes, all the cells in the range contain Formulae
Feb 25 2020 05:58 AM
Feb 25 2020 06:08 AM
Thanks for your reply, Is there any way of responding to an Excel Cell that has been changed @Jan Karel Pieterse
Feb 25 2020 06:42 AM
Feb 25 2020 06:52 AM
Sorry for my ignorance but how would i anonymize the sample workbook@Jan Karel Pieterse
Feb 25 2020 07:52 AM
Feb 25 2020 08:10 AM
Hi Jan
Thanks for your time
What I am trying to achieve is to establish if a cell in the range D2:D10 changes when the formulae is true and so shows Go. I hope that makes sense
Feb 25 2020 08:42 AM
Solution@Phil-365 You could do it like so:
Option Explicit
Dim PrevData As Variant
Private Sub Worksheet_Calculate()
Dim Rw As Long
Dim curData As Variant
If IsEmpty(PrevData) Then
PrevData = Range("D2:D10").Value2
End If
curData = Range("D2:D10").Value2
For Rw = LBound(curData, 1) To UBound(curData, 1)
If curData(Rw, 1) <> PrevData(Rw, 1) Then
MsgBox "Row " & Rw + 1 & " has changed!"
End If
Next
PrevData = Range("D2:D10").Value2
End Sub
Feb 25 2020 08:59 AM
Hi Thanks Jan
I will place it in the required program which will make an immense difference to what we are tring to achieve. I have tried it in the example Workbook which obviously works, it will take out having to test the whole of the Cell range as your code supplies the Row. Once again Thanks for your time.
Feb 25 2020 08:42 AM
Solution@Phil-365 You could do it like so:
Option Explicit
Dim PrevData As Variant
Private Sub Worksheet_Calculate()
Dim Rw As Long
Dim curData As Variant
If IsEmpty(PrevData) Then
PrevData = Range("D2:D10").Value2
End If
curData = Range("D2:D10").Value2
For Rw = LBound(curData, 1) To UBound(curData, 1)
If curData(Rw, 1) <> PrevData(Rw, 1) Then
MsgBox "Row " & Rw + 1 & " has changed!"
End If
Next
PrevData = Range("D2:D10").Value2
End Sub