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 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM