• Initiateur de la discussion Initiateur de la discussion raym1313
  • Date de début Date de début

Boostez vos compétences Excel avec notre communauté !

Rejoignez Excel Downloads, le rendez-vous des passionnés où l'entraide fait la force. Apprenez, échangez, progressez – et tout ça gratuitement ! 👉 Inscrivez-vous maintenant !

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

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
 
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 🙂
 
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
 
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
 
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
 
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
 
- Navigue sans publicité
- Accède à Cléa, notre assistante IA experte Excel... et pas que...
- Profite de fonctionnalités exclusives
Ton soutien permet à Excel Downloads de rester 100% gratuit et de continuer à rassembler les passionnés d'Excel.
Je deviens Supporter XLD

Discussions similaires

Réponses
14
Affichages
961
Réponses
6
Affichages
1 K
Réponses
2
Affichages
2 K
Retour