一起來學(xué)office,,提高辦公技能 Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim HighLightRng As Range, rng1 As Range, rng2 As Range Cells.Interior.ColorIndex = xlNone Set rng1 = ActiveCell.EntireColumn Set rng2 = ActiveCell.EntireRow If Target.Count > 1 Then Target.Interior.ColorIndex = xlNone '如果當(dāng)前選擇多個單元格,,則清除顏色 Else On Error Resume Next '如果后面的程序出現(xiàn)運行時錯誤時會繼續(xù)運行 Set HighLightRng = Application.Union(rng1, rng2) HighLightRng.Interior.ColorIndex = 40 Target.Interior.ColorIndex = 3 Set rng1 = Nothing Set rng2 = Nothing Set HighLightRng = Nothing End If End Sub |
|
來自: bitterfleabane > 《EXCEL》