- Private Sub ColorBand(ByVal rngTarget As Range) With rngTarget.Parent .Cells.Interior.ColorIndex = 0 .Columns(rngTarget.Column).Cells.Interior.ColorIndex = 35 .Rows(rngTarget.Row).Cells.Interior.ColorIndex = 35 End With End Sub 此代碼不會(huì)影響復(fù)制、剪切和粘貼功能。示例文檔見 用顏色自動(dòng)突出顯示當(dāng)前單元格行列3.xls,。UploadFiles/2006-10/1027603994.rar (4) 在工作表中有一個(gè)復(fù)選框,,用來決定是否突出顯示當(dāng)前單元格所在的行和列。即當(dāng)您選中該復(fù)選框后,,將突出顯示當(dāng)前單元格所在的行和列,。在需要設(shè)置此功能的工作表模塊中輸入下面的代碼: Private Sub CheckBox1_Change() If Me.CheckBox1.Value = False Then Me.Cells.Interior.ColorIndex = 0 End If End Sub ‘- - - - - - - - - - - - - - - - - - - - - Private Sub Worksheet_Change(ByVal target As Range) If Me.CheckBox1.Value = True Then If Application.CutCopyMode <> False Then Application.CutCopyMode = False Call ColorBand(target) End If End If End Sub ‘- - - - - - - - - - - - - - - - - - - - - Private Sub Worksheet_SelectionChange(ByVal target As Range) If Me.CheckBox1.Value = True Then If Application.CutCopyMode = False Then Call ColorBand(target) Else Exit Sub End If End If End Sub ‘- - - - - - - - - - - - - - - - - - - - - Private Sub ColorBand(ByVal rngTarget As Range) With rngTarget.Parent .Cells.Interior.ColorIndex = 0 .Columns(rngTarget.Column).Cells.Interior.ColorIndex = 35 .Rows(rngTarget.Row).Cells.Interior.ColorIndex = 35 End With End Sub 示例文檔見 用顏色自動(dòng)突出顯示當(dāng)前單元格行列4.xls。 |
|