(4) 在工作表中有一个复选框,用来决定是否突出显示当前单元格所在的行和列。即当您选中该复选框后,将突出显示当前单元格所在的行和列。在需要设置此功能的工作表模块中输入下面的代码: 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 示例文档见 用颜色自动突出显示当前单元格行列4.xls。
ERpO59Oy.rar
(8.83 KB, 下载次数: 302)
By fanjy in 2006-10-27
|