打开excel,在左下角的工作表名字上右键,然后点击“查看代码”
在出来的窗口中,双击左边的“Sheet1”,在打开的窗口中,粘贴下面的代码进去。
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)On Error Resume NextCells.FormatConditions.DeleteWith Target.EntireRow.FormatConditions '行变色.Delete.Add xlExpression, , "TRUE".Item(1).Interior.ColorIndex = 12 '颜色选择,改变该值,行的颜色会改变End WithWith Target.EntireColumn.FormatConditions'列变色.Delete.Add xlExpression, , "TRUE".Item(1).Interior.ColorIndex = 12End WithEnd Sub
参考:/question/557741756484472612.html