EXCEL UDF that returns a String of multiple string objects. Possible to color font?

  • Hi there,


    I have a udf that returns a string to the cell. The string is made up of multiple string "objects". What I am wondering is if I can set the font color of certain objects so that when the final string is built and returned, the font of those portions is set.


    Ex. of simple idea (this is not actually my code, just a way to illustrate. I realize there is no point to this UDF):


    Code
    Function StringReturn (Str1 as String, Str2 as String, Str3 as String) as String
    
    
    StringReturn = Str1 & Str2 & Str3
    
    
    End Function


    Now what if I wanted Str1 and Str3 to be blue, and Str2 to be red for example. So that when the UDF calculates it would return: Str1Str2Str3


    Thanks!

  • Re: EXCEL UDF that returns a String of multiple string objects. Possible to color fon


    It's not possible, you can't change a worksheet with a UDF and changing the format of a cell would be doing so.


    Also, the only way you can have different colours if you are dealing with a value, not the result of a formula.


    PS Strings aren't objects, they are just 'simple' variables with no properties, methods etc.

    Boo!:yikes:

  • Re: EXCEL UDF that returns a String of multiple string objects. Possible to color fon


    Alright then, thansks Norie! saves me the time trying

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!