+ Reply to Thread
Results 1 to 9 of 9

Help with VBA code to run code when a cell value increases

  1. #1
    Forum Contributor
    Join Date
    03-06-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    352

    Question Help with VBA code to run code when a cell value increases

    Hi there,

    After some help on the following code:

    Please Login or Register  to view this content.
    In A1 I have a countif formula which counts the dates in a range that are > than tomorrow.

    This code works intermittantly it seems but not all the time?

  2. #2
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Help with VBA code to run code when a cell value increases

    I could be wrong but I don't think there is an event that can detect a change in a formula. You might have to directly compare the dates in question to tomorrows date.
    If you are happy with my response please click the * in the lower left of my post.

  3. #3
    Forum Contributor
    Join Date
    03-06-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    352

    Re: Help with VBA code to run code when a cell value increases

    I don't think I am wanting to detect a change in the formula, it's more the change in the result of the formula?

  4. #4
    Forum Contributor
    Join Date
    03-06-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    352

    Re: Help with VBA code to run code when a cell value increases

    To be clear, I'm wanting a message box to appear when a date is entered in a range that is beyond tomorrow's date, or similarly if a date is changed to one beyong tomorrow's date

  5. #5
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Help with VBA code to run code when a cell value increases

    I don't think I am wanting to detect a change in the formula, it's more the change in the result of the formula?
    Correct. I don't think that is possible. I could be wrong though. It is however easy to compare a change in a cell which is reference in the formula. Need more info on that though.

  6. #6
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: Help with VBA code to run code when a cell value increases

    Not sure I understands you problem properly but you could try this:

    Right click on sheet tab where formula cell is. For instance sheet1 and past this code.

    Please Login or Register  to view this content.

    Then right click on “ThisWorkbook” and paste this code

    Please Login or Register  to view this content.
    Save file and open it again. Now try to update you formula target cell and see if MsgBox is activated.

    Alf
    Last edited by Alf; 02-02-2016 at 04:57 PM.

  7. #7
    Forum Contributor
    Join Date
    03-06-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    352

    Re: Help with VBA code to run code when a cell value increases

    Thanks for your replies, Alf, that works except it brings up the msgbox even if the result of the countif formula doesn't change?

  8. #8
    Forum Contributor
    Join Date
    03-06-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    352

    Re: Help with VBA code to run code when a cell value increases

    stnkynts all I'm trying to do is make a msgbox appear when a user enters or changes a date in a column that is after tomorrow's date, maybe this isn't the simplest way?

  9. #9
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: Help with VBA code to run code when a cell value increases

    I've tested a bit and it seems that "COUNTIF" is a special case as for instance "SUM" and "COUNT" works as exspected that is MsgBox is only activated if the result in target cell changes. Pehaps you could use another function instead of "COUNTIF"?

    Alf

+ 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. Replies: 2
    Last Post: 12-11-2014, 03:26 PM
  2. [SOLVED] Excel VB code. Message pops up while code running asking question. Code must not wait.
    By Heinrich Venter in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-28-2014, 06:10 AM
  3. Trim code to exit code if cell is empty
    By excellenthelp in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-23-2013, 12:08 PM
  4. Adding Text to another cell VB code (Help Tweeking code) (Excel 2007)
    By Excelnoub in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-06-2012, 11:37 AM
  5. Replies: 2
    Last Post: 03-17-2011, 08:55 PM
  6. [SOLVED] Compiling Excel VBA code increases workbook file size!
    By Romuald in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-01-2005, 05:06 AM

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