Excel VBA:用于将活动单元格变为粗体的功能 [英] Excel VBA: function to turn activecell to bold
本文介绍了Excel VBA:用于将活动单元格变为粗体的功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的模块内部具有以下功能.
I have the following function inside my module.
Function Colorize(myValue)
ActiveCell.Select
Selection.Font.Bold = True
Colorize = myValue
End Function
将使用此功能的单元格应该变为粗体-但是,我没有收到任何错误消息,但很遗憾,但确实如此,它没有变为粗体.我想念什么?
The cell that will use this function should be turning bold - however, I get no error messages back and sad but true, its not turning bold. What am I missing?
谢谢
推荐答案
UDF仅返回一个值,不允许您更改单元格/工作表/工作簿的属性.将代码移至Worksheet_Change事件或类似的操作以更改属性.
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.
例如
Private Sub worksheet_change(ByVal target As Range)
target.Font.Bold = True
End Sub
这篇关于Excel VBA:用于将活动单元格变为粗体的功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文