鼠标如何用不同颜色定位表格

04-22

1.实现的效果就是鼠标点到那,都有一个不同的颜色区分出,鼠标所在位置的行和列
鼠标如何用不同颜色定位表格

2.我用的版本是office 2010,打开excel,新建如下图。
鼠标如何用不同颜色定位表格

3.在sheet1下标签处,点击鼠标右键,出现如下图
鼠标如何用不同颜色定位表格

4.选择查看代码
鼠标如何用不同颜色定位表格

5.看到如下界面,插入如下代码
鼠标如何用不同颜色定位表格

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range) On Error Resume Next Cells.FormatConditions.Delete iColor = 34 With Target.EntireRow.FormatConditions .Delete .Add xlExpression, , "TRUE" .Item(1).Interior.ColorIndex = iColor End With With Target.EntireColumn.FormatConditions .Delete .Add xlExpression, , "TRUE" .Item(1).Interior.ColorIndex = iColor End WithEnd Sub
6.保存,可以看到,如下效果了,当鼠标点到那,很明显就能把行和列这样区分出来了。
鼠标如何用不同颜色定位表格