Excel VBA: function to turn activecell to bold

前端 未结 2 1678
挽巷
挽巷 2021-01-08 01:15

I have the following function inside my module.

Function Colorize(myValue)
    ActiveCell.Select
    Selection.Font.Bold = True
    Colorize = myValue
End Fu         


        
2条回答
  •  梦毁少年i
    2021-01-08 01:38

    A UDF will only return a value it won't allow you to change the properties of a cell/sheet/workbook. Move your code to a Worksheet_Change event or similar to change properties.

    Eg

    Private Sub worksheet_change(ByVal target As Range)
      target.Font.Bold = True
    End Sub
    

提交回复
热议问题