需求描述
在點擊單元格的時候,單元格所在行與列都變色顯示
實現方案
打開Excle表格,按住ALT+F11
雙擊上圖中的ThisWorkbook
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range) Cells.Interior.Pattern = xlNone Rows(Target.Row).Interior.ColorIndex = 3 Columns(Target.Column).Interior.ColorIndex = 4 End Sub
代碼中的3、4為顏色標記,具體參照下圖:
將上述代碼貼入
然后另存表格為變色.xlsm