将数据放入计时器表中以进行Excel演示

时间:2013-04-19 16:51:52

标签: excel vba excel-vba

我在某个单元格的工作表中有一个工作计时器。我需要使用预定值(在宏中或对单元格的引用中)填充工作表,并将其输入到模板中以进行演示。有没有人这样做过。我的代码是...... “是的”子没有完成,但我想让一件工作。我不能。

Sub timer()
Application.OnTime Now + TimeValue("00:00:01"), "Increment_count"
End Sub
Sub Increment_Count()
Range("AE5").Value = Range("AE5") + TimeValue("00:00:01")
timer

Application.Run ("yeah")

End Sub
Sub STOPtimer()
Application.OnTime Now + TimeValue("00:00:01"), "Increment_count", Schedule:=False
End Sub

Sub yeah()

Dim i As Integer

For i = 2 To 31
If IsError(Cells(i, 39)) = False And IsError(Cells(32, 5)) = False Then
If Cells(i, 38) = Cells(31, 5) Then
Cells(1, 8) = Cells(i, 39)
End If
End If

Next i

End Sub

1 个答案:

答案 0 :(得分:0)

您是否会在数据缓慢填充时出现过渡型效应?我认为这就是你在做的事情。对于像这样的一次性事情,计时器似乎有点不必要。(30或任何数字都不是很多)。

Declare Sub Sleep Lib "kernel32" _
(ByVal dwMilliseconds As Long)


Sub Macro1()

    Range("B1").Value = "1"
    Sleep 1000 'Implements a 1 second delay
    Range("B2").Value = "2"
    Sleep 1000 'Implements a 1 second delay
    Range("B3").Value = "3"
    Sleep 1000 'Implements a 1 second delay
    Range("B4").Value = "4"
    Sleep 1000 'Implements a 1 second delay
    Range("B5").Value = "5"
    Sleep 1000 'Implements a 1 second delay
    Range("B6").Value = "6"
    Sleep 1000 'Implements a 1 second delay
    Range("B7").Value = "7"
    Sleep 1000 'Implements a 1 second delay
    Range("B8").Value = "8"
    Sleep 1000 'Implements a 1 second delay
    Range("B9").Value = "9"
    Sleep 1000 'Implements a 1 second delay
    Range("B10").Value = "10"
    Sleep 1000 'Implements a 1 second delay
    Range("B11").Value = "11"
    Sleep 1000 'Implements a 1 second delay
    Range("B12").Value = "12"
    Sleep 1000 'Implements a 1 second delay
    Range("B13").Value = "13"
    Sleep 1000 'Implements a 1 second delay
    Range("B14").Value = "14"
    Sleep 1000 'Implements a 1 second delay
    Range("B15").Value = "15"
    Sleep 1000 'Implements a 1 second delay
    Range("B16").Value = "16"
    Sleep 1000 'Implements a 1 second delay
    Range("B17").Value = "17"
    Sleep 1000 'Implements a 1 second delay
    Range("B18").Value = "18"
    Sleep 1000 'Implements a 1 second delay
    Range("B19").Value = "19"
    Sleep 1000 'Implements a 1 second delay
    Range("B20").Value = "20"
    Sleep 1000 'Implements a 1 second delay
    Range("B21").Value = "21"
    Sleep 1000 'Implements a 1 second delay
    Range("B22").Value = "22"
    Sleep 1000 'Implements a 1 second delay
    Range("B23").Value = "23"
    Sleep 1000 'Implements a 1 second delay
    Range("B24").Value = "24"
    Sleep 1000 'Implements a 1 second delay
    Range("B25").Value = "25"
    Sleep 1000 'Implements a 1 second delay
    Range("B26").Value = "26"
    Sleep 1000 'Implements a 1 second delay
    Range("B27").Value = "27"
    Sleep 1000 'Implements a 1 second delay
    Range("B28").Value = "28"
    Sleep 1000 'Implements a 1 second delay
    Range("B29").Value = "29"
    Sleep 1000 'Implements a 1 second delay
    Range("B30").Value = "30"
    Sleep 1000 'Implements a 1 second delay
    Range("B31").Value = "31"

End Sub

通过这种方式,您可以填充组并根据需要更改效果之间的延迟。虽然是出于演示目的 - 我只是显示数据并完成它。在这方面无需让观众惊叹。但我个人偏好。祝你好运。