+ Reply to Thread
Results 1 to 6 of 6

vba to recognise change in cell value created by a formula

  1. #1
    Registered User
    Join Date
    08-26-2015
    Location
    Staffordshire UK
    MS-Off Ver
    2007
    Posts
    98

    vba to recognise change in cell value created by a formula

    I have taken this code from this forum (Thank you Kaper) and it does what I need apart from the fact that when the cell value changes it is the result of a formula calculation and the vba does not pick it up. If I change the appropriate cell (C3) manually it works fine.

    I would very much appreciate some help with this ...

    Thanks
    Paul
    Please Login or Register  to view this content.
    Moderator's note: Please take the time to review our rules. There aren't many, and they are all important. Rule #3 requires code tags. I have added them for you this time because you are a new member. --6StringJazzer
    Last edited by 6StringJazzer; 09-09-2015 at 01:33 PM.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: vba to recognse change in cell value created by a formula

    There are two ways I know of to do this.

    One is to use a static variable to store the value of C3, then use the Worksheet_Calculate event to detect a change, and when a change occurs compare the new value to the stored variable and see if it's different. This technique is illustrated in another thread.

    Another is to use Worksheet_Change to detect changes in the precedent cells in the C3 formula. What is the formula?
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    08-26-2015
    Location
    Staffordshire UK
    MS-Off Ver
    2007
    Posts
    98

    Re: vba to recognise change in cell value created by a formula

    Hi Jeff, thanks for your reply, the formula is just a simple % calc ..

    =SUM(D3/$D$34*100)

    Cheers
    Paul

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: vba to recognise change in cell value created by a formula

    Do D3 or D34 have formulas? If not then you can use this. I assume your code above is in a Worksheet module, and if so would be updated as follows:

    Please Login or Register  to view this content.
    The other technique requires a couple of other bells and whistles so I'm starting with this.

  5. #5
    Registered User
    Join Date
    08-26-2015
    Location
    Staffordshire UK
    MS-Off Ver
    2007
    Posts
    98

    Re: vba to recognise change in cell value created by a formula

    thanks very much Jeff, I'll check it out ... be tomorrow now

    Cheers
    Paul

  6. #6
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,616

    Re: vba to recognise change in cell value created by a formula

    As I was involved in original thread let me comment:
    Quote Originally Posted by 6StringJazzer View Post
    Do D3 or D34 have formulas? If not
    That's the important part. If in either D3 or D34 you have formulas then you could try to check again which cells are real "source of change" and if these cells are located in the same worksheet try to use their addresses in Worksheet_Change code.

    Otherwise (I expect this will be the case, - probably in D24 you do have a sum, don't you?) adopt this very compact code from link mentioned above: http://www.excelforum.com/excel-form...g-formula.html


    PS. I'd stick to checking if Target intersects with interesting cells. Otherwise, if we chaeck if target is one of particular cells, then if for instance someone copies a value into a range D2:D4 the code will ignore it (target is not D3).
    So my suggestion for second line in above code would be:
    Please Login or Register  to view this content.
    Best Regards,

    Kaper

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] How do you get Weeknum to recognise the change in year within a date
    By john dalton in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-17-2013, 11:42 AM
  2. [SOLVED] Using Dynamic cell reference in cell formula created by VBA
    By grazian2 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-25-2013, 11:05 AM
  3. Formula to recognise one word from multiple words in the same cell
    By JLucy in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 06-27-2013, 11:48 AM
  4. How to Recognise and Array Formula?
    By rau in forum Excel General
    Replies: 2
    Last Post: 09-08-2012, 07:15 AM
  5. Replies: 3
    Last Post: 01-11-2012, 08:17 AM
  6. Recognise change in pattern and create a space
    By bobbied in forum Excel General
    Replies: 4
    Last Post: 11-03-2010, 12:17 PM
  7. My formula does not recognise a value as a number
    By stanja in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 09-06-2009, 12:25 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1