+ Reply to Thread
Results 1 to 5 of 5

Color-code a cell based on another cell using For-each

  1. #1
    Registered User
    Join Date
    02-10-2014
    Location
    Schaumburg, IL
    MS-Off Ver
    Excel 2007
    Posts
    24

    Color-code a cell based on another cell using For-each

    Hello,

    Need help after searching then 'net. I'm writing some VBA code for Excel. I need to change the color of a cell based upon the data in another cell. This selects sheet "Kane", and searches for the word "Expenses" in a range in column D. Using For-Each, I need the IF statement that will change the cell color in the same row, but in column P.

    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

    Please Login or Register  to view this content.

    Thanks in advance for your help.
    Last edited by 6StringJazzer; 05-05-2014 at 07:03 PM.

  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,428

    Re: Color-code a cell based on another cell using For-each

    Please Login or Register  to view this content.

    But why don't you just use Conditional Formatting?

    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
    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: Color-code a cell based on another cell using For-each

    Please Login or Register  to view this content.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  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: Color-code a cell based on another cell using For-each

    On second look, I discourage depending on selected sheets in most cases. If this code is in the module for Kane, then the Select statement is not needed. Otherwise, although what you have done is not wrong, a more reliable way to code this would be

    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,428

    Re: Color-code a cell based on another cell using For-each

    Please Login or Register  to view this content.

    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. Color code cell containing a date based on day of week
    By hvercillo in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 01-05-2014, 08:21 PM
  2. Color Code Cell Containing Date Based on Day of Week
    By hvercillo in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-04-2014, 05:58 AM
  3. Replies: 5
    Last Post: 12-07-2013, 02:21 PM
  4. [SOLVED] color code cells based on changes to cell value
    By wintermelon in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-22-2013, 03:29 AM
  5. VBA code to fill cell color based on Cell Value
    By a1s2d3f4 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-05-2013, 10:19 PM

Tags for this Thread

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