+ Reply to Thread
Results 1 to 9 of 9

How to change or populate cell values based on cell colors

  1. #1
    Registered User
    Join Date
    05-01-2012
    Location
    SoCal, USA
    MS-Off Ver
    Excel 2010
    Posts
    7

    How to change or populate cell values based on cell colors

    Hello,

    I want to "Change a cell value based on cell color".

    And, if possible, "Change a range or group of cell values based on cell colors (that vary)"

    The only reason I am looking to do this is because I cannot find out how to "shuffle" this group of cells. Originally I wanted to assign these cells numbers and shuffle the whole box (range) randomly.

    So to get around that, I created a 10x10 table of cells with grouped fill colors, then assigned all cells random values with the =RAND() function, then sorted the box based on the random values, copy/pasted a transposed box, resorted, transposed, etc, until I had a completely random box of colors. Now I would like to assign each color it's own value, while keeping the colors exactly where they are. So for example, there are 4 green boxes in my diagram. I'd like to assign all 4 green boxes with a value of 20. There are 8 black boxes in my diagram. I'd like to assign each black box with a value of 10.

    See attached for my diagram. It should be noted that this is a miniature example version of my real project, which is many thousands of cells and would be virtually impossible to do manually.

    Also, I had posted this same question in this thread as a reply, but was told that is not allowed (my apologies for that). Here is the relevant thread for reference.

    http://www.excelforum.com/excel-gene...ell-color.html


    Thanks very much!
    Attached Files Attached Files
    Last edited by MrMacroMan; 05-01-2012 at 02:35 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    07-29-2009
    Location
    Belgium
    MS-Off Ver
    Excel 2003/Excel 2010
    Posts
    534

    Re: How to change or populate cell values based on cell colors

    See if the attachment does what you're looking for.
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    05-01-2012
    Location
    SoCal, USA
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: How to change or populate cell values based on cell colors

    Quote Originally Posted by WHER View Post
    See if the attachment does what you're looking for.
    That looks brilliant! One question though. What do you mean by add an "associated value"? When I add in the values in column O and hit F9, nothing happens so I think I am missing something, especially since your next step is to change the values and hit F9 again. But if I can get that working, this solves my question perfectly.

  4. #4
    Forum Expert
    Join Date
    06-26-2010
    Location
    Austin, TX
    MS-Off Ver
    Excel 2010
    Posts
    1,673

    Re: How to change or populate cell values based on cell colors

    Wow, all that work to shuffle...
    Here is a link to one of my posts which has a shuffle algorithm.
    http://www.excelforum.com/excel-gene...html?p=2729104

    Shouldn't be too hard to modify (I infer MrMacroMan knows macros).

    Pauley

  5. #5
    Valued Forum Contributor
    Join Date
    07-29-2009
    Location
    Belgium
    MS-Off Ver
    Excel 2003/Excel 2010
    Posts
    534

    Re: How to change or populate cell values based on cell colors

    By "adding an associated value" i mean the following: for example color some cells in the 10X10 table bright green(color as in N5), then add the number "30" to cell O5 (=associate "30" with bright green), then hit F9, the newly colored (green) cells should now display "30".
    This is how it works for me.

  6. #6
    Registered User
    Join Date
    05-01-2012
    Location
    SoCal, USA
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: How to change or populate cell values based on cell colors

    Quote Originally Posted by Pauleyb View Post
    Wow, all that work to shuffle...
    Here is a link to one of my posts which has a shuffle algorithm.
    http://www.excelforum.com/excel-gene...html?p=2729104

    Shouldn't be too hard to modify (I infer MrMacroMan knows macros).

    Pauley
    Hi Pauley,

    Thanks for that link. Either a shuffle or the color coded table like what WHER posted will work for me. I looked over your algorithm, and while I am definitely known as the macro guy by the folks around me, I think it's more realistic to say that I am just a big fish in a small pond there. I've built many macros that some would say are advanced, but I think mine are on a more intermediate level compared to some of you on here. So what I am really saying is that no I actually do not know how to modify that to fit my diagram. If you see a quick way to sort of "fill in the blanks" for my diagram, I think I could take that and apply it to my larger project.

    Whether you do or don't, thanks for answering

  7. #7
    Registered User
    Join Date
    05-01-2012
    Location
    SoCal, USA
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: How to change or populate cell values based on cell colors

    Quote Originally Posted by WHER View Post
    By "adding an associated value" i mean the following: for example color some cells in the 10X10 table bright green(color as in N5), then add the number "30" to cell O5 (=associate "30" with bright green), then hit F9, the newly colored (green) cells should now display "30".
    This is how it works for me.
    Hi WHER,

    Your sheet works perfectly for me as well. But I meant that it does not work when I recreate it in my own sheet. I've got all the same formulas in there, but for some reason, the table is not linking to the color index range. Specifically the "fmr". When I am in the formula (on yours) and hit F2, I can see that "fmr" is linking to the color index columns. In mine, it does not. Please see attached and let me know if you can spot where I am going wrong.

    Thanks!
    Attached Files Attached Files

  8. #8
    Valued Forum Contributor
    Join Date
    07-29-2009
    Location
    Belgium
    MS-Off Ver
    Excel 2003/Excel 2010
    Posts
    534

    Re: How to change or populate cell values based on cell colors

    Ok, i see. "frm" is a named formula that you have to define yourself under "Names".
    To see what i mean, open my attachment (post 2), select cell B2, then ctrl+F3 will open the "Name manager". Now you should see the
    named formula "frm". Look at the formula in the "refers to" box (with B2 still selected, important because parts of the formula are "relative") and take note of it.
    Now recreate the same named formula in your own workbook (also with B2 selected). The actual name (frm) is not important, it's just a random name.

  9. #9
    Registered User
    Join Date
    05-01-2012
    Location
    SoCal, USA
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: How to change or populate cell values based on cell colors

    Absolutely perfect. I did not realize that you had put a named formula in there.

    Anyway... I am now able to recreate this at whatever scale I need.

    Thanks so much WHER.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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