As far as I experienced, you cannot format cells (like cahngingfont, colors, etc) within functions. It only works in Subroutines.