Microsoft Excel 2003 VBA Timer

Da wollte ich doch mal schnell eine UserForm in meine Excelmappe einfügen damit wenn sie startet ein Fenster aufgeht was sich nach 20 sekunden wieder schließt und eine Funktion ausführt.

Aber nix da! In Excel existiert das Timer werkzeug nicht 🙁
Noch mal schnell gegoogelt aber das richtig war nicht dabei also selbst was machen 🙂

Und ich finde mein ergebniss kann sich sehen lassen geht bestimmt 1000 mal besser aber so gehts auch 😛

Code:

Dim i As Integer
Dim bolAbbruch As Boolean

‚Button zum Abbrechen des Timers

Private Sub cmdAbbrechen_Click()
bolAbbruch = True

End Sub

‚Wird beim öffnen oder aktivieren der UserForm gestartet
Private Sub UserForm_Activate()

DoEvents
Call MYTimer

End Sub

‚Die Tolle Timer funktion 😉
Function MYTimer()

DoEvents
i = 0
Do
If i < 20 Then
Call onesec
i = i + 1
End If

txtZeit = 20 – i

DoEvents
Loop Until i = 20 Or bolAbbruch = True

If bolAbbruch = False Then
Call Programm_Ausfuehren
Else
Unload Me
End If

Debug.Print Time

End Function

‚Dieses Funktion wartet immer eine sekunde
Function onesec() As Boolean

strsek = Second(Time)
Do
DoEvents
Loop While Second(Time) = strsek

onesec = True

End Function

‚Die Funktion die am ende der 20 Sekunden aufgerufen wird
Function Programm_Ausfuehren()

MsgBox „test“
Unload Me

End Function

Google Tags:

excel timer function

Eine Antwort auf „Microsoft Excel 2003 VBA Timer“

  1. I am really loving the theme/design of your web site. Do you ever run into any web browser compatibility problems? A small number of my blog visitors have complained about my site not working correctly in Explorer but looks great in Chrome. Do you have any tips to help fix this issue?

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.