问题
I've written a user defined function and want to change the font format of a defined character range, of the return value.
It doesn´t seem to work the way i expekt, for cells with functions "= ..." . I only got 2 scenarios, first formated the whole return value and second doesn't format anything. For "normal" cells, is works, as you can see in the screenshot.
try to change font format of first char to purple: top cell with function, botton cell without function:
Anyone have an idea, how to do it correctly?
Iam thankful about every answer / hint i can get! Greetings Leo
Edit 03.12.2020 Thank you for all your answers and hints, some of you asked for code, here it is:
Public Function format(val As String)
With Application.Caller
.Characters(1, 1).Font.Color = RGB(255, 0, 255)
End With
With Application.Caller.Offset(1, 0)
.Characters(1, 1).Font.Color = RGB(255, 0, 255)
End With
format = val
End Function
So if you type some chars manually under the "function cell", for example "abcd", you should get following result (screenshot)
Top before running function, bottom after running function:
来源:https://stackoverflow.com/questions/65110841/change-font-from-returne-value-of-udf-in-vba-using-range-characters-property