Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1263 connectés 

  FORUM HardWare.fr
  Programmation
  VB/VBA/VBS

  si je saisie une date(x) à quelle heure "Entrée 1" a été mise en march

 

Sujet(s) à lire :
    - Visual C++
 

 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

si je saisie une date(x) à quelle heure "Entrée 1" a été mise en march

n°2165475
dadex85
merci a tous
Posté le 26-11-2012 à 15:48:51  profilanswer
 

Bonjour à tous,
 
je veux faire un script en VBA :
si je saisie une date(x) à quelle heure "Entrée 1" a été mise en marche et à quelle heure elle a été arrêtée.
si je saisie une date(x) à quelle heure le "ok" a débuté et à quelle heure il a pris fin.
je voudrais avoir une macro pour chacun si possible.
 
 
 
22/11/2012
07:26:29  ---- Mise en marche --- Entree 1 --- MARCHE
22/11/2012
16:26:31  ---- Mise en marche ---Entree 1 --- ARRET
 
22/11/2012
07:26:50          ok
22/11/2012
16:26:56        ok  
22/11/2012
16:26:59            ok  
22/11/2012
16:27:02          ok  
22/11/2012
16:27:04          ok  
22/11/2012
16:27:12          ok  
22/11/2012
16:27:14               ok  
22/11/2012
16:27:16              ok  
22/11/2012
16:27:18                ok  
22/11/2012
16:27:20            ok
 
cordialement


Message édité par dadex85 le 26-11-2012 à 15:50:30

---------------
david
mood
Publicité
Posté le 26-11-2012 à 15:48:51  profilanswer
 

n°2166016
dadex85
merci a tous
Posté le 29-11-2012 à 12:13:26  profilanswer
 

J'ai trouvé une solution à mon problème, je vous met le code au cas ou xa interesserait quelqu'un :
 
Private Sub CommandButton1_Click()
Dim m As Integer, Date_Réf As Date, Ligne_fin As Integer, Date_Réf_Col As Integer, Date_Réf_Lig As Integer
Dim Réf_Marche As String, Réf_Arrêt As String, Réf_Ok_Début As String, Réf_Ok_Fin As String
 
Application.ScreenUpdating = False
Ligne_fin = Range("A1048576" ).End(xlUp).Row
 
On Error GoTo Etiquette
Date_Réf = InputBox("Quelle est la date choisie ?" )
Etiquette:
If Date_Réf = 0 Then
    MsgBox ("La saisie n'est pas une date" )
    Exit Sub
End If
 
Range("A17" ).Activate
 
Do Until ActiveCell = Date_Réf
    ActiveCell.Offset(1, 0).Activate
    If ActiveCell.Row = Ligne_fin + 10 Then
        MsgBox ("Date introuvable" )
        Exit Sub
    End If
Loop
 
Date_Réf_Col = ActiveCell.Column
Date_Réf_Lig = ActiveCell.Row
 
On Error Resume Next
 
Do
m = 0
m = WorksheetFunction.Search("Entree 1 --- MARCHE", ActiveCell.Offset(1, 0))
If m > 0 Then Réf_Marche = Left(ActiveCell.Offset(1, 0), 8)
ActiveCell.Offset(1, 0).Activate
Loop Until m > 0
 
Cells(Date_Réf_Lig, Date_Réf_Col).Activate
Do
m = 0
m = WorksheetFunction.Search("Entree 1 --- ARRET", ActiveCell.Offset(1, 0))
If m > 0 Then Réf_Arrêt = Left(ActiveCell.Offset(1, 0), 8)
ActiveCell.Offset(1, 0).Activate
Loop Until m > 0
 
Cells(Date_Réf_Lig, Date_Réf_Col).Activate
Do
m = 0
m = WorksheetFunction.Search("---- ON ----", ActiveCell.Offset(1, 0))
If m > 0 Then Réf_Ok_Début = Left(ActiveCell.Offset(1, 0), 8)
ActiveCell.Offset(1, 0).Activate
Loop Until m > 0
 
 
'On part à l'envers pour la dernière référence
Range("A" & Ligne_fin).Activate
 
Do Until ActiveCell = Date_Réf
    ActiveCell.Offset(-1, 0).Activate
Loop
 
Do
m = 0
m = WorksheetFunction.Search("---- ON ----", ActiveCell.Offset(1, 0))
If m > 0 Then Réf_Ok_Fin = Left(ActiveCell.Offset(1, 0), 8)
ActiveCell.Offset(-1, 0).Activate
Loop Until m > 0
 
MsgBox (Date_Réf & vbNewLine & vbNewLine & "Mise en marche : " & vbNewLine & Réf_Marche & vbNewLine & vbNewLine & "Arrêt : " & vbNewLine & Réf_Arrêt & vbNewLine & vbNewLine & "Début Production : " & vbNewLine & Réf_Ok_Début & vbNewLine & vbNewLine & " Fin Production : " & vbNewLine & Réf_Ok_Fin)
 
End Sub
 
 
cordialement


Message édité par dadex85 le 29-11-2012 à 12:14:28

---------------
david

Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  VB/VBA/VBS

  si je saisie une date(x) à quelle heure "Entrée 1" a été mise en march

 

Sujets relatifs
autoriser une annimation en fonction de la date du jour sous powerpoin[MySQL] champs date et suite de row consecutive...
faire une somme par heure,jour,mois...mise en ligne site flash avec formulaire de contact
Vérification d'heureProblème de mise en place d'image en bouton submit
CVS : lister les fichiers modifiés depuis une certaine dateExcel: Mise en forme
[JavaScript] Masques de saisie sur formulaire 
Plus de sujets relatifs à : si je saisie une date(x) à quelle heure "Entrée 1" a été mise en march


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR