+ Reply to Thread
Results 1 to 5 of 5

VBA function which returs colored result depending on the value

  1. #1
    Registered User
    Join Date
    08-24-2015
    Location
    Poland
    MS-Off Ver
    2010
    Posts
    3

    VBA function which returs colored result depending on the value

    Hi,

    Is it possible to create a function, which result would be colord depending on the value?

    Let's say that I want my function to refer to the A1 Cell. A1 value is 0,9 and the result should be simply 0,9 but it should also be colored green (because it's higher than 0,5). I don't want to use conditional formatting here, because this function will be nested nextly in text like below:

    ="the value is " & XXX(A1) & " and it is below the target" - and I would like only the result of function XXX to be colored.

    Thanks in advance for all your support!

  2. #2
    Forum Expert
    Join Date
    02-22-2013
    Location
    London, UK
    MS-Off Ver
    Office 365
    Posts
    1,218

    Re: VBA function which returs colored result depending on the value

    You could try numberformatting for the coloring, like:

    "[Green][>5]"the values is" 0 "and it's ...";General"

    provided the cell is a pure number and the text would be part of the its numberformat

  3. #3
    Registered User
    Join Date
    08-24-2015
    Location
    Poland
    MS-Off Ver
    2010
    Posts
    3

    Re: VBA function which returs colored result depending on the value

    Do you mean something like below:

    Capture.PNG

    I think that I entered it incorrectly, because it's not working

    One more question, would it be possible to include more conditions this way? <0,2 - Red, <0,5 - Yello, >0,5 - Green?

  4. #4
    Forum Expert
    Join Date
    02-22-2013
    Location
    London, UK
    MS-Off Ver
    Office 365
    Posts
    1,218

    Re: VBA function which returs colored result depending on the value

    Try C1 as a pure number with no text in it (text will be in the number formatting), =A1

    and work with the number formatting, like:

    [Red][<0.2]"the values is" 0.0 "and it's below 0.2";[Green][>0.5]"the values is" 0.0 "and it's below the target";[Yellow]"the values is" General

    See attached.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    08-24-2015
    Location
    Poland
    MS-Off Ver
    2010
    Posts
    3

    Re: VBA function which returs colored result depending on the value

    Thank you for your fast replies. But what I would like to have is only the value of cell A1 colored, not the whole text. So for example I would like to have "45%" (please see below picture) colored.

    Capture.PNG


    Would it be possible?

+ 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. [SOLVED] Making one of two sounds depending on the result of a "if" function
    By pierre86 in forum Excel General
    Replies: 6
    Last Post: 01-11-2015, 08:21 PM
  2. [SOLVED] VLOOKUP function returs #N/A error
    By boboivan in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-21-2014, 02:10 PM
  3. Cell colour depending on Max result.
    By FerrumIgnotus in forum Excel General
    Replies: 6
    Last Post: 03-09-2012, 11:12 AM
  4. Need predefined result depending on input
    By okicizepa in forum Excel General
    Replies: 1
    Last Post: 07-22-2010, 05:35 AM
  5. Row Colour Depending On Drop Down Result
    By cjconnor24 in forum Excel General
    Replies: 5
    Last Post: 07-10-2007, 04:42 PM
  6. [SOLVED] Colour cell (or text) depending upon IF Function result
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-25-2006, 11:35 AM
  7. [SOLVED] How do I change the color of a cell depending on the result of the function in that cell
    By Mo Childs in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-02-2005, 06:20 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