全心思齐网

在excel里怎样用函数改变字体?

excel中函数无法对字体、颜色进行操作,但是好在excel内置了VBA来实现这些功能。操作步骤:

1、在excel界面,按ALT+F11打开VBA编辑器。

2、在VBA编辑器中选择插入-->模块复制以下代码:Sub tst()Dim cel As RangeFor Each cel In Range("a1:a5")If cel.Value > 3 ThenWith cel.Font.ColorIndex = 3.Name = "Calibri"End WithEnd IfNextEnd Sub3、全选代码,按F5执行即可实现对字体、颜色的设置。

匿名回答于2019-06-19 01:32:30


相关知识问答