+ Reply to Thread
Results 1 to 7 of 7

Worksheet_Change procedure when multiple cells are involved

  1. #1
    Registered User
    Join Date
    11-15-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2007
    Posts
    97

    Worksheet_Change procedure when multiple cells are involved

    In my application, I have the following requirement:

    If there is a change in cell D10 and the value is "COMPANY" then the text colors of certain cell should change to red

    OR

    If there is a change in cell E23 and the value is "YES" then the text colors of certain cells should change to red

    OR

    If there is a change in cell E34 and the value is "YES" then the text colors of certain cells should change to red

    The cells in which the color should change to red are different in each of the three conditions above.

    I am able to do it for change in one of the cells (either D10, E23 or E34) but not not able to modify the code to cover any of the three conditions. The code I have used for change in one cell is given below:

    Please Login or Register  to view this content.
    Can someone help modifying this code to cover any of the three conditions. If a completely different code is required, that is also accepted.

    Regards,

    Anandvh
    Last edited by anandvh; 05-22-2015 at 05:53 PM. Reason: solved

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,364

    Re: Worksheet_Change procedure when multiple cells are involved

    Please Login or Register  to view this content.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    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: Worksheet_Change procedure when multiple cells are involved

    Hello anandvh,

    If Range("I10:L10") is associated with D10, then what ranges are associated with E23 and E34? Please provide complete information.
    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!)

  4. #4
    Registered User
    Join Date
    07-28-2007
    Posts
    35

    Re: Worksheet_Change procedure when multiple cells are involved

    something like this?
    (not tested)
    Please Login or Register  to view this content.

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,364

    Re: Worksheet_Change procedure when multiple cells are involved

    This

    Please Login or Register  to view this content.
    will exit the Change event handler if one of the other cells is changed. You probably need to make a union of rng1, rng2 and rng3 and test that.

    Regards, TMS

  6. #6
    Registered User
    Join Date
    11-15-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2007
    Posts
    97

    Re: Worksheet_Change procedure when multiple cells are involved

    TMS - Thanks a ton for the quick solution. The code you gave has been tested and is working like a dream. I will have to study the code you sent to understand the differences with the various options I was trying. Clearly I have a long way to go in getting a hand of programming. Your second response has been ignored since I had already tried out a code similar to what mperrah has provided but did not work

    mperrah - Thanks for the response. The code you have sent was one of the versions that I was trying and failing. None of the text in any of the cells changed color. Thanks anyway for your efforts.

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,364

    Re: Worksheet_Change procedure when multiple cells are involved

    You're welcome.

    Please Login or Register  to view this content.

    You don't actually need to disable event handling as you're not changing the values, just the formatting.


    Regards, TMS

+ 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. Worksheet_Change not firing when pasting to multiple cells.
    By bg819 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-17-2014, 11:41 AM
  2. Worksheet_Change procedure I need to modify
    By pglufkin in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-13-2013, 03:05 PM
  3. Conditional Formatting with multiple sheets involved
    By AMSBenji in forum Excel General
    Replies: 36
    Last Post: 05-01-2013, 10:08 PM
  4. Replies: 0
    Last Post: 10-15-2012, 07:24 AM
  5. Unable to hide columns in another worksheet from within worksheet_change procedure
    By mjeanes in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-08-2012, 09:39 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