+ Reply to Thread
Results 1 to 11 of 11

Macro to conditional format text box colour

  1. #1
    Forum Contributor
    Join Date
    03-06-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    352

    Macro to conditional format text box colour

    Hello,

    I am after a macro to change the colour of a textbox according to whether a cell contains a number that is:

    <80 it needs to be red
    >90 needs to be green
    Anything else then it needs to be orange.

    Can anyone help?

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,053

    Re: Macro to conditional format text box colour

    Sorry - misread the request. Ignore this post of mine!!
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  3. #3
    Valued Forum Contributor
    Join Date
    08-22-2011
    Location
    Auckland
    MS-Off Ver
    Excel 2019
    Posts
    716

    Re: Macro to conditional format text box colour

    Try this.
    Type a value into A1 to see the box change colour

    Please Login or Register  to view this content.
    Attached Files Attached Files

  4. #4
    Forum Contributor
    Join Date
    03-06-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    352

    Re: Macro to conditional format text box colour

    Thanks for the reply - i get an error on the intersect part of the code.

    The code with my small changes is below:

    Please Login or Register  to view this content.

  5. #5
    Valued Forum Contributor
    Join Date
    08-22-2011
    Location
    Auckland
    MS-Off Ver
    Excel 2019
    Posts
    716

    Re: Macro to conditional format text box colour

    Please Login or Register  to view this content.
    Or
    Please Login or Register  to view this content.
    Is the most likely cause. If not, attach an example

  6. #6
    Forum Contributor
    Join Date
    03-06-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    352

    Re: Macro to conditional format text box colour

    Same error - just 1 question. Should it be on the code for the sheet where the text box is or where the cell is? (it's two different sheets)

  7. #7
    Valued Forum Contributor
    Join Date
    08-22-2011
    Location
    Auckland
    MS-Off Ver
    Excel 2019
    Posts
    716

    Re: Macro to conditional format text box colour

    If it's on 2 sheets then that code won't work.
    What's the sheet name or number for the textbox & the cell?
    Or post an example to make life easy

  8. #8
    Forum Contributor
    Join Date
    03-06-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    352

    Re: Macro to conditional format text box colour

    Aha that problem is now sorted thanks. One more thing - at the moment it only changes on the cell change, how can I get it to change on the whole worksheet change?

  9. #9
    Valued Forum Contributor
    Join Date
    08-22-2011
    Location
    Auckland
    MS-Off Ver
    Excel 2019
    Posts
    716

    Re: Macro to conditional format text box colour

    By that do you mean any cell on the worksheet? If so this code will do it. You'll have to sort out the finer points as you haven't posted an example

    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    03-06-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    352

    Re: Macro to conditional format text box colour

    No sorry I just mean I want the macro to run on the change of any cell in the worksheet, not that any cell in the worksheet can be the cell with >80 or <90 etc

  11. #11
    Valued Forum Contributor
    Join Date
    08-22-2011
    Location
    Auckland
    MS-Off Ver
    Excel 2019
    Posts
    716

    Re: Macro to conditional format text box colour

    Try this,it colours the textbox when you enter a value in any cell & changes the colour to white if you delete any cell with a value.
    It's my last effort today as it's way past my bedtime
    Have a play & change things around etc

    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. Conditional Format colour Text
    By Puggwash63 in forum Excel General
    Replies: 4
    Last Post: 12-13-2014, 09:08 AM
  2. [SOLVED] Conditional format colour of Shape as Macro Button
    By deancorleone in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-16-2013, 10:33 AM
  3. Excel 2007 : Conditional cell format (colour)
    By Lonely Ranger in forum Excel General
    Replies: 0
    Last Post: 04-26-2009, 07:39 AM
  4. Conditional Format colour
    By meridklt in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 08-04-2007, 05:19 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