modif sur un chrono

raym1313

XLDnaute Occasionnel
bonjour a tous

j ai une macro qui affiche un chrono
cette macro fonctionne parfaitement ( grace a vous d'ailleurs :) )

je souhaiterai qu'au bout de 2h - arret du chrono sans qu'il se remette a zero
et qu'une msgbox m'affiche un message
je vous ai joint un petit fichier

merci pour votre aide

amicalement
raymond:)
 

Pièces jointes

  • modif chrono.xls
    27 KB · Affichages: 52

skoobi

XLDnaute Barbatruc
Re : modif sur un chrono

Bonjour raym1313,

voici l'ensemble du module modifié (en bleue les ajouts):

Code:
[B][COLOR=blue]Public début[/COLOR][/B]
Public prochainchrono
Public chrono
Sub majchrono()
temp = chrono / 3600
Sheets("feuil1").[b5] = Format(temp / 24, "hh:mm:ss")
chrono = chrono + 1
prochainchrono = Now + TimeValue("00:00:1")
[B][COLOR=blue]If prochainchrono = début + TimeValue("02:00:00") Then[/COLOR][/B]
[B][COLOR=blue]  MsgBox "fin du temps réglementaire."[/COLOR][/B]
[B][COLOR=blue]  Exit Sub[/COLOR][/B]
[B][COLOR=blue]End If[/COLOR][/B]
Application.OnTime prochainchrono, "majchrono"
End Sub
Sub auto_close()
On Error Resume Next
Application.OnTime prochainchrono, procedure:="majchrono", schedule:=False
End Sub
Sub demarre()
If Sheets("feuil1").[b5].Value > 0 Then
Sheets("feuil1").[b5].Value = 0
Exit Sub
End If
[B][COLOR=blue]début = Now[/COLOR][/B]
chrono = 0
majchrono
End Sub
 

raym1313

XLDnaute Occasionnel
Re : modif sur un chrono

re bonjour

et merci beaucoup cela fonctionne parfaitement


je vais abuser de ta gentillesse je souhaiterai ameliorer cette macro
en ajoutant lors du message box un signal ou plusieurs beep

et c'est le clic sur le ok qui arreterait ce signal

qu'en penses tu est ce possible


amicalement
raymond :)
 

JCGL

XLDnaute Barbatruc
Re : modif sur un chrono

Bonjour à tous,
Salut Skooby,
Salut Raymond,

Peux-tu essayer avec ce code de Skooky, sonorisé.... arf

Code:
Public début
Public prochainchrono
Public chrono
Sub majchrono()
[COLOR=blue][B]Dim x%[/B][/COLOR]
temp = chrono / 3600
Sheets("feuil1").[b5] = Format(temp / 24, "hh:mm:ss")
chrono = chrono + 1
prochainchrono = Now + TimeValue("00:00:1")
If prochainchrono = début + TimeValue("02:00:00") Then
 
MsgBox "fin du temps réglementaire.", [B][COLOR=blue]vbCritical[/COLOR][/B]
[B][COLOR=blue]For x = 1 To 5000[/COLOR][/B]
[B][COLOR=blue]Beep[/COLOR][/B]
[B][COLOR=blue]Next[/COLOR][/B]
Exit Sub
End If
Application.OnTime prochainchrono, "majchrono"
End Sub
Sub auto_close()
On Error Resume Next
Application.OnTime prochainchrono, procedure:="majchrono", schedule:=False
End Sub
Sub demarre()
If Sheets("feuil1").[b5].Value > 0 Then
Sheets("feuil1").[b5].Value = 0
Exit Sub
End If
début = Now
chrono = 0
majchrono
End Sub

A+ mes amis
A+ à tous
 

raym1313

XLDnaute Occasionnel
Re : modif sur un chrono

re bonsoir

j ai pris le code de JC

Public début
Public prochainchrono
Public chrono
Sub majchrono()
Dim x%
temp = chrono / 3600
Sheets("feuil1").[b5] = Format(temp / 24, "hh:mm:ss")
chrono = chrono + 1
prochainchrono = Now + TimeValue("00:00:1")
If prochainchrono = début + TimeValue("02:00:00") Then

MsgBox "fin du temps réglementaire.", vbCritical
For x = 1 To 5000
Beep
Next
Exit Sub
End If
Application.OnTime prochainchrono, "majchrono"
End Sub
Sub auto_close()
On Error Resume Next
Application.OnTime prochainchrono, procedure:="majchrono", schedule:=False
End Sub
Sub demarre()
If Sheets("feuil1").[b5].Value > 0 Then
Sheets("feuil1").[b5].Value = 0
Exit Sub
End If
début = Now
chrono = 0
majchrono
End Sub

quel modification dois je apporter
tu me propose de faire une modif avant le msg
comment ?

merci de me corriger le code

amicalement
raymond
 

roro69

XLDnaute Impliqué
Re : modif sur un chrono

Bonsoir
Je me permet de te répondre car je vois que jcgl,et skoobi sont hors ligne;comme skoobi la marqué la haut il faut mettre la boucle juste avant le message.
Public début
Public prochainchrono
Public chrono
Sub majchrono()
Dim x%
temp = chrono / 3600
Sheets("feuil1").[b5] = Format(temp / 24, "hh:mm:ss")
chrono = chrono + 1
prochainchrono = Now + TimeValue("00:00:1")
If prochainchrono = début + TimeValue("02:00:00") Then
For x = 1 To 5000
Beep
Next

MsgBox "fin du temps réglementaire.", vbCritical

Exit Sub
End If
Application.OnTime prochainchrono, "majchrono"
End Sub
Sub auto_close()
On Error Resume Next
Application.OnTime prochainchrono, procedure:="majchrono", schedule:=False
End Sub
Sub demarre()
If Sheets("feuil1").[b5].Value > 0 Then
Sheets("feuil1").[b5].Value = 0
Exit Sub
End If
début = Now
chrono = 0
majchrono
End Sub
Bonne soirée
Et surtout un merci à sko0bi Et JCGL
 

roro69

XLDnaute Impliqué
Re : modif sur un chrono

REbonsoir RAYMOND si comme tu me le dis çà ne marche toujours pas essaye ce bout de code:
Public début
Public prochainchrono
Public chrono
Sub majchrono()
Dim x%
temp = chrono / 3600
Sheets("feuil1").[b5] = Format(temp / 24, "hh:mm:ss")
chrono = chrono + 1
prochainchrono = Now + TimeValue("00:00:1")
If prochainchrono = début + TimeValue("00:00:10") Then 'Change ici en 02:00:00
Beep
ElseIf prochainchrono = début + TimeValue("00:00:11") Then 'Change ici en 02:00:01


MsgBox "fin du temps réglementaire.", vbCritical

Exit Sub
End If
Application.OnTime prochainchrono, "majchrono"
End Sub
Sub auto_close()
On Error Resume Next
Application.OnTime prochainchrono, procedure:="majchrono", schedule:=False
End Sub
Sub demarre()
If Sheets("feuil1").[b5].Value > 0 Then
Sheets("feuil1").[b5].Value = 0
Exit Sub
End If
début = Now
chrono = 0
majchrono
End Sub
 

Discussions similaires

Membres actuellement en ligne

Statistiques des forums

Discussions
313 344
Messages
2 097 337
Membres
106 916
dernier inscrit
Soltani mohamed