以下是引用ldy在2007-10-21 0:44:00的发言:太复杂了 没有细看 ,但以下代码也能实现 颜色改变事件 Private Sub CommandButton1_Click() Dim s As String, s1 As String Dim RG As Range, Tr As Boolean If CommandButton1.Caption <> "停止" Then CommandButton1.Caption = "停止" Else CommandButton1.Caption = "开始" End If Do While CommandButton1.Caption = "停止" a = ActiveCell.Interior.ColorIndex s = ActiveCell.Address Set RG = ActiveCell Do While a = RG.Interior.ColorIndex DoEvents s1 = ActiveCell.Address If s1 <> s Or CommandButton1.Caption = "开始" Then Tr = True Exit Do End If Loop If Tr = False Then MsgBox s & "变色了" Tr = False s = ActiveCell.Address Loop End Sub 呵呵,Do Loop在DoEvents状态下不断循环检查太吃资源了! 实用性不大,用API可以实现,代码很复杂
|