我試圖使用下面的宏,但它甚至沒有將其識別爲宏,因此我無法運行該宏。如果我把第一個改成只是「private/public sub test()」,它會運行,然後它說我的Target對象沒有被定義。Excel 2010宏,突出顯示有效單元格的行
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
Cells.Interior.ColorIndex = 0
With Target
' Highlight the entire row and column that contain the active cell
.EntireRow.Interior.ColorIndex = 8
.EntireColumn.Interior.ColorIndex = 8
End With
Application.ScreenUpdating = True
End Sub
確保您的代碼連接到一個表,這個用來工作表一個標準的事件。 –