EXCEL电子表格单击单元格自动改变颜色代码

2023-04-12 04:19:21   文档大全网     [ 字体: ] [ 阅读: ]

#文档大全网# 导语】以下是®文档大全网的小编为您整理的《EXCEL电子表格单击单元格自动改变颜色代码》,欢迎阅读!
单击,表格,单元,颜色,改变

1、右键单击工作表(左下方工作表名称),选择查看代码。

2、写入以下内容,即可改变单元格颜色

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Target.Interior.Color = vbYellow

End Sub

3.1、写入以下内容,即可改变整行颜色

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If i = 0 Then i = 1

Rows(i).Interior.Pattern = xlNone

i = Target.Row

Rows(i).Interior.Color = vbYellow

End Sub

3.2、写入以下内容,即可改变整列颜色

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If i = 0 Then i = 1

Rows(i).Interior.Pattern = xlNone

i = Target.Row

Selection.EntireColumn.Interior.Color = vbYellow

End Sub

3.3、整行变色继续单击变色移动

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Rows().Interior.ColorIndex = 0

x = ActiveCell.Row

Rows(x).Interior.ColorIndex = 9

End Sub

本文来源:https://www.wddqxz.cn/6a03a43303020740be1e650e52ea551810a6c905.html

相关推荐