I'm trying to set a cell's font to being Italic, and all VBA references I've seen have told me to do it
cell.Font.Italic = True as so:
Function Test(testcell As Range)
testcell.Font.Italic = True
Test = testcell.Font.Italic
End Function
But unless the passed-in cell is already Italic the function always returns FALSE with no change to the cell in question.
I've tried using the FontStyle property and even hard coding the cell value, but the cell refuses to change.
Function Test(testcell As Range)
Range("J95").Font.FontStyle = "Italic"
Test = testcell.Font.Italic
End Function
The only way to get the function to return TRUE is to manually set the cell to Italic from the Ribbon, but obviously, that's not what I want.
It's not that simple.
UDFs called indirectly with theEvaluatemethod can do much more than regularUDFs, but they also don't have the full capabilities of macros. Among other things, they can't set attributes forItalicorBoldfonts.In this case, use another workaround to run the macro. This can be done, for example, by using the
Calculateevent.In the standard module, you need to put the code:
And in the worksheet module, the
Calculateevent handler: