1、首先在开发工具中打开VBA编辑器

2、在单元格区域当中输入一些内容作为例子

3、在VBA编辑器中插入模块

4、在模块当中输入如下代码,然后运行
Sub adc()
On Error Resume Next '出错继续执行后面的代码
'Worksheets("Sheet1").Range("A1").Font.ColorIndex = 3
'Selection.Font.ColorIndex = 5
'Range("A1:A11").Select '选择辅助的区域
'Selection.Copy '复制
'Range("A13").Select '选择粘贴的第一个单元格
'ActiveSheet.Paste '粘贴
'Selection.Font.ColorIndex = 5 '字的颜色号为3 红色
Selection.Interior.ColorIndex = 44 ' 背景的颜色为3 红色
'Selection.Font.Color = RGB(0, 255, 0) '字的颜色绿色
'Selection.Interior.Color = RGB(0, 0, 255) '背景的颜色蓝色
End Sub

5、或者
Sub adc()
On Error Resume Next '出错继续执行后面的代码
'Worksheets("Sheet1").Range("A1").Font.ColorIndex = 3
'Selection.Font.ColorIndex = 5
'Range("A1:A11").Select '选择辅助的区域
'Selection.Copy '复制
'Range("A13").Select '选择粘贴的第一个单元格
'ActiveSheet.Paste '粘贴
'Selection.Font.ColorIndex = 5 '字的颜色号为3 红色
'Selection.Interior.ColorIndex = 44 ' 背景的颜色为3 红色
'Selection.Font.Color = RGB(0, 255, 0) '字的颜色绿色
Selection.Interior.Color = RGB(0, 0, 255) '背景的颜色蓝色
End Sub

6、最后就可以看到我们成功的设置了单元格的背景颜色,
