根据先前的单元格值更改单元格颜色

时间:2017-08-09 05:48:43

标签: excel-vba timer vba excel

我是宏观新手。

我有一个宏:

Private Sub Worksheet_Calculate()

Dim x As Single, colIndx As Integer
i = 1

For Each cell In Range("B2:B23")
    If cell.Value > val(i) Then
        colIndx = cell.Interior.ColorIndex
        x = Timer
        While Timer - x < 0.5
            cell.Interior.ColorIndex = 5
        Wend
        cell.Interior.ColorIndex = colIndx
        val(i) = cell.Value
    End If
    i = i + 1
Next cell

For Each cell In Range("B2:B23")
    If cell.Value < val(i) Then
        colIndx = cell.Interior.ColorIndex
        x = Timer
        While Timer - x < 0.5
            cell.Interior.ColorIndex = 3
        Wend
        cell.Interior.ColorIndex = colIndx
        val(i) = cell.Value
    End If
    i = i + 1
Next cell
End Sub

它将cell(b2:b23)颜色改变0.5秒。我希望将此用于b到k行并持续2秒。但是tmer不支持超过1秒。我该如何更改?

0 个答案:

没有答案