Excel精英培训网

 找回密码
 注册
数据透视表40+个常用小技巧,让你一次学会!
12
返回列表 发新帖
楼主: uranus1997

[分享] 一个由单元格颜色改变触发的事件--类模块应用

[复制链接]
发表于 2007-10-23 19:43 | 显示全部楼层

几天没来,这么多东东啦!

学习!

回复

使用道具 举报

发表于 2008-6-8 08:22 | 显示全部楼层
回复

使用道具 举报

发表于 2008-6-9 11:50 | 显示全部楼层

QUOTE:
以下是引用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可以实现,代码很复杂

回复

使用道具 举报

发表于 2010-10-19 16:48 | 显示全部楼层

再来看看!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|Excel精英培训 ( 豫ICP备11015029号 )

GMT+8, 2024-6-1 05:57 , Processed in 0.241185 second(s), 6 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表