Excel选中单元格时自动高亮所在行列

 转载需注明来源:https://www.cnblogs.com/yczcc/p/7976620.html 

excel 高亮 单元格 选中单元格

“工作表”右键,“查看代码”,

 VBA代码编辑器中,选择“Worksheet”

在Worksheet_SelectionChange函数中添加如下代码:

Target.Parent.Cells.Interior.ColorIndex = xlNone
Target.EntireColumn.Interior.ColorIndex = 36
Target.EntireRow.Interior.ColorIndex = 36

最后整个函数如下:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Target.Parent.Cells.Interior.ColorIndex = xlNone
    Target.EntireColumn.Interior.ColorIndex = 36
    Target.EntireRow.Interior.ColorIndex = 36
End Sub

保存,关闭即可。

效果:

 转载需注明来源:https://www.cnblogs.com/yczcc/p/7976620.html 

posted @ 2017-12-04 13:19  yczcc  阅读(23469)  评论(0编辑  收藏  举报