Functions aren't meant to change formatting etc. only return a value.
Have your code called from a Worksheet Change event:
Private Sub Worksheet_Change(ByVal Target As Range)
'call your macro here (your macro can remain in a standard code
'module)
End Sub
This should be in the worksheet code module of the worksheet you want
this to happen in. Use Target instead of Activecell or Selection.