为什么在动画后填充标题?

时间:2016-04-18 19:17:38

标签: excel vba excel-vba

我有一个Excel VBA函数,它修改了两个字段flashes the background color for one of them的内容。这是我的代码:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Dim cellTitle As Range
    Set cellTitle = Range("J2")
    Dim cellTip As Range
    Set cellTip = Range("J3")
    Title = Application.VLookup(Target.Address, Sheets("Settings").Range("TipsDashboard"), 2, False)
    If Not IsError(Title) Then
        Tip = Application.VLookup(Target.Address, Sheets("Settings").Range("TipsDashboard"), 3, False)
        cellTitle.Value = Title
        cellTip.Value = Tip
        FadeToWhite (Sheets("Dashboard").Range("$J$3:$K$9"))
    End If
End Sub

Sub FadeToWhite(c As Range)
    Const SLOWNESS As Long = 50000
    Dim i As Long, v
    For i = 1 To 255 * SLOWNESS
        If i Mod SLOWNESS = 0 Then
            v = i / SLOWNESS
            c.Interior.Color = RGB(v, 255, v)
            DoEvents
        End If
    Next i
End Sub

出于某种原因,它会填充cellTip的值,颜色渐渐消失,然后会填充cellTitle的值。我的延迟最终会慢得多,但SLOWNESS的较大值确实会使时间变得明显。

我意识到这是一个微不足道的细节,但我真的很想知道它为什么会发生。

0 个答案:

没有答案