+ Reply to Thread
Results 1 to 10 of 10

VBA won't execute when formula changes cell value

  1. #1
    Registered User
    Join Date
    11-26-2013
    Location
    Here
    MS-Off Ver
    Excel 2003
    Posts
    11

    VBA won't execute when formula changes cell value

    Hi all,

    I'm having a hard time getting this to work;

    VBA executes the code when value of a cell is "X"

    When the value of a cell is changed to "x" due to a formula (=IF(A3+A5=4,"x",0)), unfortunately VBA will not be triggered unless I manually put an 'X' into the cell.

    Can any one help me out with this?


    the code is use:

    Please Login or Register  to view this content.
    Last edited by Intern2; 12-30-2013 at 11:52 AM.

  2. #2
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: VBA won't execute when formula changes cell value

    Formula does not raise Change event. You may use Calculate event or adapt Change event to look for changes in cells referred to by formula.
    • Please remember to mark threads Solved with Thread Tools link at top of page.
    • Please use code tags when posting code: [code]Place your code here[/code]
    • Please read Forum Rules

  3. #3
    Registered User
    Join Date
    11-26-2013
    Location
    Here
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: VBA won't execute when formula changes cell value

    Thank you for your prompt answer Izandol!

    I'm kind of a noob in VBA, just started using it recently. If I understand correctly, vba won't be executed, because it doesn't see a change, a formula as not a target cell.
    Cause of my lack of skill, I cant produce the answer in code myself, would you be able to help me out with it?

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: VBA won't execute when formula changes cell value

    Intern2,
    Please use code tags with your code as per forum's rule.

  5. #5
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: VBA won't execute when formula changes cell value

    I must see workbook to change the code. Calculate event has no Target parameter and so the code must test all the required formula cells, or the Change event must test input cells for changes but I do not know where they are.

  6. #6
    Registered User
    Join Date
    11-26-2013
    Location
    Here
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: VBA won't execute when formula changes cell value

    Quote Originally Posted by AB33 View Post
    Intern2,
    Please use code tags with your code as per forum's rule.
    Ah sorry, I will look into the forum rools on how to do that!

  7. #7
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: VBA won't execute when formula changes cell value

    Click the edit button on post #1. Then highlight the entire code, click the # sign ( # is found on quick reply menu).

  8. #8
    Registered User
    Join Date
    11-26-2013
    Location
    Here
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: VBA won't execute when formula changes cell value

    @AB33: done

    Find the excel file attached,
    The concerning sheet = sheet2 ("Needs to be sorted"),
    When "X" is entered in the first column, the entire row will be cut and pasted in Sheet3 ("DOC").
    Attached Files Attached Files

  9. #9
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: VBA won't execute when formula changes cell value

    You may try this instead of your codes:
    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    11-26-2013
    Location
    Here
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: VBA won't execute when formula changes cell value

    Thank you soo much for your help Izandol! The code seems to work perfect!
    Really appreciate it!

+ 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. IF cell=error execute sub 1 if value execute sub 2... possible?
    By CDNcameron in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-31-2013, 05:28 PM
  2. Modify formula to not execute if cell contains certain text
    By icets in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 06-26-2011, 08:59 PM
  3. Execute a formula Indirectly
    By TomTheTrader in forum Excel General
    Replies: 2
    Last Post: 01-22-2008, 08:01 AM
  4. execute once formula
    By tekman in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-07-2005, 01:52 PM
  5. Replies: 4
    Last Post: 01-20-2005, 05:40 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