Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default SheetChange for formulas

I've noticed that if a change the value of a cell that affects a formula for
that cell the Worksheet.Change event is triggered but for the cell with the
formula is not.

Is there a way to determine if the value of a formula has changed?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default SheetChange for formulas

Normally a formula cell will contain a refer to one or more precedents, of
which at least one is likely to be a cell you can look for changes in a
change event.

Alternatively, start by storing the old formula value, then comparing at the
end of a Calculate event, eg

Make B4 a formula cell, eg =Sum("B2:B3")

in the worksheet module (rt-click sheet tab, view code)

Dim mbStored As Boolean
Dim mV As Variant

Private Sub Worksheet_Calculate()
Debug.Print Range("B4").Value
With Range("B4")

If Not mbStored Then
mV = "last value stored"
End If
Range("C4").Value = mV

mV = .Value
End With
mbStored = True
End Sub

Initialize (ie store the old value) by causing a recalc, or manually
Ctrl-Alt-F9
Look at cell C4

Regards,
Peter T



"ARHangel" wrote in message
...
I've noticed that if a change the value of a cell that affects a formula

for
that cell the Worksheet.Change event is triggered but for the cell with

the
formula is not.

Is there a way to determine if the value of a formula has changed?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default SheetChange for formulas

Is there a way without knowing the cells with formulas?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default SheetChange for formulas

In theory maybe yes but difficult to comment without any details as to what
you have and what you want. At the very least it would need to be tailored
to your set-up and requirements.

Regards,
Peter T

"ARHangel" wrote in message
...
Is there a way without knowing the cells with formulas?



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default SheetChange for formulas

If anyone interested I've found a solution.

use Range.Dependents - gives you all the cells that are formulas and the
formulas "contains" the Range
or
Range.SpecialCells(xlCellFormulas) - gives you all the cells in the Range
that are formulas

"Peter T" wrote:

In theory maybe yes but difficult to comment without any details as to what
you have and what you want. At the very least it would need to be tailored
to your set-up and requirements.

Regards,
Peter T

"ARHangel" wrote in message
...
Is there a way without knowing the cells with formulas?




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cause of SheetChange Event Matthew Wieder[_3_] Excel Programming 6 April 25th 07 10:16 PM
SheetChange fire UDF unintentionally Peter Excel Programming 2 March 21st 06 02:12 PM
SheetChange Event Tom Ogilvy Excel Programming 0 November 23rd 04 07:10 PM
SheetChange Event crispbd[_34_] Excel Programming 0 November 23rd 04 06:43 PM
XLapp and SheetChange strataguru[_5_] Excel Programming 1 October 8th 03 04:39 PM


All times are GMT +1. The time now is 09:33 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"