I wrote code to extract data from the URL a particular page.
First time I run the code it extracts data from URL to cell C1
.
I am at a point where I want to display a MsgBox
whenever cell value changes.
For example:
First time I run the code
"Happy"
gets extracted to cell C1.
(Cell value changes, so msgbox "value changed")The second time I run the code then Also
"Happy"
gets extracted to the cell C1.
(means no change, Noting happens)The third time I run the code and
"Sad"
gets extracted to cell C1,
so at this point, I want a msgbox of the cell change.
I tried the below code but it shows the msgbox even when same values are changed in the cell.
For example - Cell contains text "Happy"
. I rewrite "Happy"
in cell and press enter, so it displays msgbox of cell changed despite being same text in the cell.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim KeyCells As Range
' The variable KeyCells contains the cells that will
' cause an alert when they are changed.
Set KeyCells = Range("A1:C10")
If Not Application.Intersect(KeyCells, Range(Target.Address)) Is Nothing Then
' Display a message when one of the designated cells has been
' changed.
' Place your code here.
MsgBox "Cell " & Target.Address & " has changed."
End If
End Sub