This article was previously published under Q133049
Retired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.
In Microsoft Excel, a function cannot automatically format text based onthe type of value it returns. However, you can create a custom numberformat that will return different colored text, based on whether yourfunction returns a positive, negative, or zero value.
In Microsoft Excel, number formats are based on the following:
[color1]positive# format;[color2]negative# format;[color3]zero# format
To have a function return up to three different types of text value, eachwith a different color, have the function return either a positive number,a negative number, or a zero value, and format the custom number formatsuch that it displays text based on those values. For example, thefollowing custom number format
will display the word "after" in red if the function returns a positivenumber, the word "before" in blue if the function returns a negative value,and the word "same" in green if the function returns 0.