+ Reply to Thread
Results 1 to 16 of 16

How do I modify the colour of a text box that is linked to the value of a cell

  1. #1
    Registered User
    Join Date
    07-31-2014
    Location
    Bucharest
    MS-Off Ver
    2007
    Posts
    6

    How do I modify the colour of a text box that is linked to the value of a cell

    Hello,

    I have 2 sheets in an excel file. One that contains data, and one that contains text boxes. I'm applying conditional formatting in the data sheet (it's numbers, gradient colors)

    Does anybody know any code that I could use so that the text box colors it's self automatically (either to press a button etc) with the same color that appears in the cell that is linked to?

    This is MS Office 2007 I'm talking about

    Thank you

  2. #2
    Forum Contributor Jack7774's Avatar
    Join Date
    08-31-2012
    Location
    Georgia, US
    MS-Off Ver
    Excel 2010
    Posts
    576

    Re: How do I modify the colour of a text box that is linked to the value of a cell

    May I see an example of what you have and what you want it to look like?
    Thank those who have helped you by clicking the Star * below their name and please mark your post [SOLVED] if it has been answered satisfactorily.

  3. #3
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,942

    Re: How do I modify the colour of a text box that is linked to the value of a cell

    You need to identify the correct textbox - but then using the change event of the data sheet, you can use

    Please Login or Register  to view this content.
    Bernie Deitrick
    Excel MVP 2000-2010

  4. #4
    Registered User
    Join Date
    07-31-2014
    Location
    Bucharest
    MS-Off Ver
    2007
    Posts
    6

    Re: How do I modify the colour of a text box that is linked to the value of a cell

    Hello all,

    Thanks for the answers, but this is not the solution. On the data sheet I have numbers that will change daily, and it's not 1,2,3 but some amounts, so the coloring of the text boxes should be in scale, as the conditional formatting is comparing all the values from the lowest to the biggest.

    There are about 75 text boxes in the diagram sheet (it's actually a map on which I added text boxes in front interests points), and each text box is linked to to a specific cell in the Data sheet.

    Example: Text box 1 is linked to o2, which has a value of 1258745.56, Text box 2 is linked to s8 which has a value of 546.22 etc.

    The reason I need this is to have a visual look of the map with interests points. So what I would need is a macro that reads color from a cell in the data sheet and puts it as background of a text box. Example: If color of Data!b2 is rgb(255,0,7) than textbox 3 (which is linked to Data!b2) should have the same color

    Thanks again

  5. #5
    Forum Contributor Jack7774's Avatar
    Join Date
    08-31-2012
    Location
    Georgia, US
    MS-Off Ver
    Excel 2010
    Posts
    576

    Re: How do I modify the colour of a text box that is linked to the value of a cell

    Upload something as an example of what it is that you want with the desired solution and that will most likely help us understand better. Thanks.

  6. #6
    Forum Contributor Jack7774's Avatar
    Join Date
    08-31-2012
    Location
    Georgia, US
    MS-Off Ver
    Excel 2010
    Posts
    576

    Re: How do I modify the colour of a text box that is linked to the value of a cell

    As far as a macro to recognise color here is an example below. As far as writing you a macro for you without you having to do the work please upload something.

    Please Login or Register  to view this content.
    Here are the color indexs
    http://www.excel-pratique.com/en/vba/colors.php

  7. #7
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,942

    Re: How do I modify the colour of a text box that is linked to the value of a cell

    One way would be to create your map with "cutouts" that allow parts of cells to be seen at the points of interest, and use the same CF on the cells that show through, linking them as required, and formatting them as ;;; to hide any linked value. If a cutout covers more than one cell, all the visible cells can all be linked to the same value so that the formatting coverage is complete.

  8. #8
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,431

    Re: How do I modify the colour of a text box that is linked to the value of a cell

    You should be able to modify Bernies' approach.

    Please Login or Register  to view this content.
    If you change the value of Data!B2 and the CF associated with it the text box on Map will update.
    Attached Files Attached Files
    Cheers
    Andy
    www.andypope.info

  9. #9
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,942

    Re: How do I modify the colour of a text box that is linked to the value of a cell

    I like that - and I especially like the DisplayFormat property. I've learned something today!

  10. #10
    Registered User
    Join Date
    07-31-2014
    Location
    Bucharest
    MS-Off Ver
    2007
    Posts
    6

    Re: How do I modify the colour of a text box that is linked to the value of a cell

    Hi Andy,

    Thanks a lot for the solution, I see it works in your file, but whenever I'm trying to implement it to mine it doesn't work.
    Can you be more specific to where I implement this code? I tried to assign the macro directly to the cell but it doesn't work.

    As I could see the text box is already filled in with the color (I don't know whether by the macro or manual). I've changed the CF of Data!B2 to another color and it hasn't replicate the color to the text box.

    Please advise,

    Radu
    Last edited by radu.niculescu; 08-02-2014 at 04:15 AM.

  11. #11
    Registered User
    Join Date
    07-31-2014
    Location
    Bucharest
    MS-Off Ver
    2007
    Posts
    6

    Re: How do I modify the colour of a text box that is linked to the value of a cell

    Hi Andy,

    Thanks a lot for the solution, I see it works in your file, but whenever I'm trying to implement it to mine it doesn't work.
    Can you be more specific to where I implement this code? I tried to assign the macro directly to the cell but it doesn't work.

    As I could see the text box is already filled in with the color (I don't know whether by the macro or manual). I've changed the CF of Data!B2 to another color and it hasn't replicate the color to the text box.

    Please advise,

    Radu

  12. #12
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,431

    Re: How do I modify the colour of a text box that is linked to the value of a cell

    Once you change the CF you need to update the cell by changing or reentering the value. This will cause the change event to fire for the sheet and the code will update the textbox.

    Conditional formatting change will not fire an event. So if the CF for B2 is based on formula from other cell you will need to capture a different event or specify which cells to capture.

    If you are still stuck post example file so we can see what is actually happening

  13. #13
    Registered User
    Join Date
    07-31-2014
    Location
    Bucharest
    MS-Off Ver
    2007
    Posts
    6

    Re: How do I modify the colour of a text box that is linked to the value of a cell

    Thank you Andy, I got the idea now. So my next question, in my file, where do I insert the macro?

  14. #14
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,431

    Re: How do I modify the colour of a text box that is linked to the value of a cell

    Right click sheet tab of the data worksheet and post code in that sheet object

  15. #15
    Registered User
    Join Date
    07-31-2014
    Location
    Bucharest
    MS-Off Ver
    2007
    Posts
    6

    Re: How do I modify the colour of a text box that is linked to the value of a cell

    Hi Andy,

    I managed to put the source to the page, it works, but only when I modify cell by cell (it doesn't work when I put information in multiple cells).
    And also I have multiple columns of information on the data sheet. How do I modify the macro to modify the color of text boxes for multiple sheets .
    I've tried to copy the code below the first one, changed the worksheet name to the other ones, but I receive an error.

    Thanks in advance,

    Radu
    Last edited by radu.niculescu; 08-03-2014 at 04:41 AM.

  16. #16
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,431

    Re: How do I modify the colour of a text box that is linked to the value of a cell

    You only need the code in the object of the sheet with the values in.
    If you have shapes on multiple sheets then you will need to alter the sheet object that is used.
    If target is a range of more than 1 cell you will need to loop through the cells.

    Please Login or Register  to view this content.

+ 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. Replies: 2
    Last Post: 07-22-2012, 05:10 PM
  2. [SOLVED] Macro to change text colour of adjacent cell to the same text colour as target cell
    By kayoke in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 06-28-2012, 04:18 AM
  3. Replies: 2
    Last Post: 06-07-2011, 07:00 AM
  4. Replies: 1
    Last Post: 04-05-2006, 01:59 AM
  5. [SOLVED] Fill colour a cell from the linked cell
    By Stephen C in forum Excel General
    Replies: 1
    Last Post: 09-28-2005, 11:05 AM

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