我正在嘗試使宏突出顯示當前單元格的整個行。我在其他地方找到了下面的代碼,雖然它突出顯示了整行,但它也從以前着色的單元格中移除顏色。VBA突出顯示當前行(不刪除所有單元格顏色)
我想要發生的是,選擇一個單元格(可能已被着色)時,整個行會突出顯示,但是當我移動到另一行中的單元格時,之前突出顯示的行將返回到其先前的顏色。
我希望找到的是一段代碼,它允許修改先前選定的單元格/行。我是VBA的新手,所以很抱歉,如果這非常簡單!
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
Application.ScreenUpdating = False
' Clear the color of all the cells
Target.Parent.Cells.Interior.ColorIndex = 0
With Target
' Highlight the entire row and column that contain the active cell
.EntireRow.Interior.ColorIndex = 8
End With
Application.ScreenUpdating = True
End Sub
這個偉大的工程!謝謝 :) – Sarchwalk