VBA to read cell value rather than the cell formula

austicks84

New Member
Joined
May 8, 2018
Messages
11
I would like a message box to pop up when a cell in a range changes. The cells in the range all have IF formulas in them. My problem is that the code i am using seems to only read the formula, which doesn't change, hence nothing happens. How can i get my code to read the cell value, which does change, rather than the formula which doesn't?

Private Sub Worksheet_Change(ByVal Target As Range)
If Not (Application.Intersect(Range("ED45:EO83"), Target) Is Nothing) Then
MsgBox "Cell " & Target.Address & " has changed.", vbInformation, "Kutools for Excel"
End If
End Sub
 
From post #1
Private Sub Worksheet_Change(ByVal Target As Range)
If Not (Application.Intersect(Range("ED45:EO83"), Target) Is Nothing) Then
MsgBox "Cell " & Target.Address & " has changed.", vbInformation, "Kutools for Excel"
End If
End Sub

From post #8
This is what's in the target cell:

=VALUE(IF(COUNTIF($P$3:$P$42,R7), 1,2))

Hi

From what I understand from these 2 posts the cell with the formula you posted is one of the cells in the range ED45:EO83 and you want to perform some action when one of these cells changes value.
Since the cell is not modified, the value just changes automatically when the formula is evaluated, the Change event is not fired.

The usual solution to this case is to check which cell is modified.
When a cell with a formula changes value this means that one of its precedents was modified.

You have to analyse the formula and check which precedent is modified and check it with the Change event.

Let me give you the gist of it with a very simple example.

Let's say that in B1 you have the formula =A1+1
You want to execute some code when B1 changes value.
Since B1 has a formula you analyse it and check that the value in B1 changes when you modify the value in A1.
In this case you want to execute a code when the value of B1 changes but you use the Change event on cell A1.

Hope this helps.
 
Upvote 0

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"

Forum statistics

Threads
1,214,589
Messages
6,120,415
Members
448,960
Latest member
AKSMITH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top