+ Reply to Thread
Results 1 to 7 of 7

Code not working on Cells with Formulas

  1. #1
    Registered User
    Join Date
    03-27-2008
    Posts
    75

    Code not working on Cells with Formulas

    Hi Guys-

    I have this simple code:
    Please Login or Register  to view this content.
    I'm targeting cells with formulas so the code doesn't work. If I paste the formulas as values the code works. Is there anyway to leave the formulas and make the code work?

    Thanks.
    Last edited by Leith Ross; 12-17-2009 at 03:39 PM. Reason: Added Code Tags

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Code not working on Cells with Formulas

    Hello Starbwoy,

    To make your posts easier to read, copy, and edit please wrap your code. I did it for you this time. Here is how you can do it next time.

    How to wrap your Code
    1. Select all your code using the mouse.
    2. Click on the # icon on the toolbar in the Message window. This will automatically wrap the text you selected with the proper Code tags to create a Code Window in your post.
    3. To do it manually...
    Use the Bulletin Board Code Tags
    [code]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/code] at the end of the last line.


    To learn more about BB codes used in this forum, just click on the link below...

    Bulletin Board Codes Tags
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    03-27-2008
    Posts
    75

    Re: Code not working on Cells with Formulas

    Thanks. I will remember that for next time.

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Code not working on Cells with Formulas

    Hello Starbwoy,

    The Value property will retyrn the formula if the cell has one. Since all your comparisons are text, use the Text property of the cell.
    Please Login or Register  to view this content.

  5. #5
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Code not working on Cells with Formulas

    A change in a formulas value will not trigger the change event.

    If Sheet1!B1 holds the formula =Sheet2!A1+1

    Entering Sheet2!A1 will trigger Sheet2's Change event, change the value of Sheet1!B1, but Sheet1's change event will not trigger.

    To put it another way, if a cell holds a formula it will never be the Target of a Change event.

    The work-around for that is to test for precident cells. For example, this will show a message when the formula in B1 changes Value

    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  6. #6
    Registered User
    Join Date
    03-27-2008
    Posts
    75

    Re: Code not working on Cells with Formulas

    I think I may be doing something wrong the cells are not changing color automatically. I have to re-past them to change color. Any idea why?
    Last edited by starbwoy; 12-17-2009 at 05:04 PM.

  7. #7
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Code not working on Cells with Formulas

    Hello Starbwoy,

    You should post your workbook. We can then review all your code. Please remove or change any information that is sensitive or confidential. You should also update your profile to reflect which version or versions of Excel you are using.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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