首页 > 技术文章 > Excel单元格定位横竖变色

cj1698 2020-11-09 20:25 原文

1、在需要设置此功能的工作簿界面,按下Alt F11键,打开VBA编程界面,双击sheet,输入如下代码:

 

 

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Cells.Interior.ColorIndex = xlNone

Target.EntireRow.Interior.ColorIndex = 24

Target.EntireColumn.Interior.ColorIndex = 24

End Sub

2、保存后关闭编程界面,回到工作簿,效果实现。

 

推荐阅读