我希望在EXCEL表格中,选中某一个单元格时,能够突出显示该单元格所在的行和列,有办法么?

2024-11-06 11:02:01
推荐回答(3个)
回答1:

右键SHEET名,查看代码
复制代码
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells.Interior.ColorIndex = xlNone
tr = Target.Row
tc = Target.Column
Rows(tr).Interior.ColorIndex = 41
Columns(tc).Interior.ColorIndex = 41
End Sub
41表示颜色代码,根据你喜好,修改41

回答2:

打开vba双击左侧的sheet1,把下面的代码复制进去即可:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells.Interior.ColorIndex = 0
Target.EntireRow.Interior.ColorIndex = 28
Target.EntireColumn.Interior.ColorIndex = 28
End Sub

回答3:

点击视图下的阅读模式