excel vba使单元格闪烁/闪烁

时间:2016-07-13 23:45:54

标签: excel colors cell

我试图让一个单元格闪存一段有限的时间。到目前为止我的代码(在其他成员的帮助下)是:

Option Explicit

Dim waitTime As Date, stopTime As Date

Function startFlash(x As String)
    Beep
    stopTime = Now + TimeSerial(0, 2, 0)
    'Debug.Print stopTime
    Call sflash
    MsgBox "done"
End Function

Sub sflash()

    Sheet1.Range("c8").Font.ColorIndex = 3

    Do While waitTime <= stopTime

        With Sheet1.Range("c8").Font
            If .ColorIndex = 3 Then
              .ColorIndex = 5
             Else
              .ColorIndex = 3
            End If
        End With

        waitTime = Now + TimeSerial(0, 0, 5)
        'Debug.Print Now; waitTime; stopTime

        Do While Now < waitTime: DoEvents: Loop
    Loop

End Sub

使用以下代码从工作表中的单元格调用此过程:

=if(C8>25,"yup",startFlash(C8))

C8中有一个数字。

当它成功运行并正确地遍历循环时,colorIndex值会随着每次迭代而改变。但是,在消息&#34;完成&#34;之后,单元格C8不会改变颜色。弹出。

我有没有

尝试过
application.screenupdating = false/true

之前和之后&#39; /&#39;以&#39;结尾。

当ColorIndex改变时,我找不到使细胞改变颜色的解决方案,即使细胞闪烁/闪烁。任何帮助将不胜感激。

0 个答案:

没有答案