Condition qui s'exécute même fausse

dmoluc

XLDnaute Occasionnel
Re bonjour à tous

J'ai une condition que je répète une bonne vingtaine de fois et qui ne fonctionne pas :

Dim A
Code:
A = ListBox11.Value
If Range("A45:A39").Find(A, LookIn:=xlValues, lookat:=xlWhole) Is Nothing Then
Range("A45").End(xlUp).Offset(1, 0) = A

Le code s'exécute même si première condition est fausse, j'ai essayé tout un tas de syntaxe et rien n'y fait.
Je pense que le problème vient des ListBox car si je fais un test dans un module les conditions fonctionnent parfaitement.

Code:
A ="Essais"
If Range("A45:A39").Find(A, LookIn:=xlValues, lookat:=xlWhole) Is Nothing Then
Range("A45").End(xlUp).Offset(1, 0) = A

Encore mes maigres connaissances qui me jouent un tour ou est-ce un mystère de l'informatique :rolleyes:

Je joint le lien du fichier et J'explique un peu car ça commence à être une vraie usine à gaz :( : Le problème est dans l'UserForm5, onglet déboursé pour la tâche, Bouton renseigner le planing. L'userform s'appel depuis la feuille Programme des travaux avec le bouton Rendement et sous détail

http://cjoint.com/?3Hmqo4gWdff

Merci pour votre aide toujours précieuse

Didier
 

bika

XLDnaute Nouveau
Re : Condition qui s'exécute même fausse

Bonjour

N'est ce pas une question de niveau de définition de variable? As-tu essayé de remplacer A par Userform5.ListBox11.Value? (je n'ai pas pu essayer, j'ai un message d'erreur quand j'essaie d'appeler l'userform)

Par ailleurs on écrit "accueil" et non "acceuil" (qui se prononcerait acsseuil), tu as fait plusieurs fois la faute dans tes onglets.

cdlt

Philippe
 

JNP

XLDnaute Barbatruc
Re : Condition qui s'exécute même fausse

Bonjour le fil :),
Depuis quand ListBox a une propriété Value qui renvoie la ligne sélectionnée :eek: ?
Jette un œil dans l'aide VBA à LiistBox et Selected, ça fonctionnera beaucoup mieux :rolleyes:...
Bon courage :cool:
 

dmoluc

XLDnaute Occasionnel
Re : Condition qui s'exécute même fausse

Merci à tous
parfois et je ne sais pas pourquoi (il commence a y avoir pas mal de code) sur la Feuil1 du texte s'inscrit en cellule A17 que j'utilise pour faire le calcul de la date avec ajout de jour ouvrés et cela empêche le lancement de l'UserForm5
Encore pardon pour mon orthographe surtout avec accueil que je suis incapable d'écrire sans me concentrer :(
Le projet est presque achevé mis à part le dernier bouton que j'essais de coder, bien sur il y aura sans doute quelques bugs à corrigés mais si cela peu servir à quelqu'un faite le circuler. C'est pas Project mais cela fait des choses que MS Project ne sais pas faire

Je vais essayer le code à Bebere en espérant que cela fonctionne et je vous tien au courant

Cordialement

Didier
 

dmoluc

XLDnaute Occasionnel
Re : Condition qui s'exécute même fausse

Bonjour JNP

. Selected je n'arrive pas à le faire fonctionner, mais avec le code de Bebere pas de problème cette fois-ci, je vais pouvoir avancer un peu plus et me dégoter de nouveau problèmes que je ne sais pas résoudre

Dim A
A = ListBox11.Value
If Application.CountIf(Range("A39:A45"), "=" & A) = 0 Then
Range("A45").End(xlUp).Offset(1, 0) = A
A = ""
End If

Ha oui, j'ai beaucoup de problème a comprendre la déclaration des variables alors je les mets souvent en variable four tout quand je vois que ça bug :rolleyes:

Merci encore de vous intéréssez à mon modeste travail que je ne pourrais pas mener à terme sans votre aide...
 

Bebere

XLDnaute Barbatruc
Re : Condition qui s'exécute même fausse

bonjour Gelinotte,JNP
si tu employes With... End With mettre un point devant l'objet(ex:.cells,.range)(déjà signalé par un répondant)
pour réduire les lignes de code,à tester
Code:
For i = 11 To 16
If Application.CountIf(.Range("A39:A45"), "=" & Me("Listbox" & i)) = 0 Then .Range("A45").End(xlUp).Offset(1, 0) = A
Next
il y a certainement moyen de faire plus simple un peu partout
malheureusement je ne sais rien testé(excel2003)
si tu as plusieurs if employer elseif(touche F1 aide)
 

dmoluc

XLDnaute Occasionnel
Re : Condition qui s'exécute même fausse

Merci,
Je vais en tenir compte surtout que j'ai rajouté plusieurs dizaines lignes de codes pour remplir et colorer le graphique, Je ne dois pas être loin de la capacité maximale de la procédure :( et je n'ai pas fini
Je pense qu'il est possible de faire une boucle au lieu de répéter les If ou ElseIf mais c'est encore une chose que je ne maîtrise pas bien

Voilà le code encore incomplet du bouton, pour aujourd'hui j'arrête mais j'espère que demain j'en viendrais à bout surtout que maintenant la fin n'est pas loin et il ne me restera plus qu'à corriger que quelques petits bugs à droite et à gauche :rolleyes:

Bonsoir et encore un grand merci

Code:
Private Sub CommandButton10_Click()
On Error GoTo ETIQUETTE
With Sheets("Programme des travaux")

Dim L As Long, C As Long
C = 4
L = Range("A36").End(xlUp).Row
Cells(L, C).Value = TextBox85.Value
Unload UserForm1
With Cells(L, C)
ActiveSheet.Unprotect
If ListBox35 = "M²" Then
.NumberFormat = "#,##0.0 ""M²"""
End If
If ListBox35 = "M³" Then
.NumberFormat = "#,##0.0 ""M³"""
End If
If ListBox35 = "Forfait" Then
.NumberFormat = "#,##0.0 ""F"""
End If
If ListBox35 = "ML" Then
.NumberFormat = "#,##0.0 ""ML"""
End If
If ListBox35 = "Unitée" Then
.NumberFormat = "#,##0.0 ""Unt."""
End If
If ListBox35 = "Tonne" Then
.NumberFormat = "#,##0.0 ""T"""
End If
If ListBox35 = "Kg" Then
.NumberFormat = "#,##0.0 ""Kg"""
End If
If ListBox35 = "Litre" Then
.NumberFormat = "#,##0.0 ""L"""
End If
End With

Dim A
A = ListBox11.Value
If Application.CountIf(Range("A39:A45"), "=" & A) = 0 Then
Range("A45").End(xlUp).Offset(1, 0) = A
End If
A = ListBox12.Value
If Application.CountIf(Range("A39:A45"), "=" & A) = 0 Then
Range("A45").End(xlUp).Offset(1, 0) = A
End If
A = ListBox13.Value
If Application.CountIf(Range("A39:A45"), "=" & A) = 0 Then
Range("A45").End(xlUp).Offset(1, 0) = A
End If
A = ListBox14.Value
If Application.CountIf(Range("A39:A45"), "=" & A) = 0 Then
Range("A45").End(xlUp).Offset(1, 0) = A
End If
A = ListBox15.Value
If Application.CountIf(Range("A39:A45"), "=" & A) = 0 Then
Range("A45").End(xlUp).Offset(1, 0) = A
End If
A = ListBox16.Value
If Application.CountIf(Range("A39:A45"), "=" & A) = 0 Then
Range("A45").End(xlUp).Offset(1, 0) = A
End If

M = ListBox27.Value
If Application.CountIf(Range("A39:A45"), "=" & M) = 0 Then
Range("A83").End(xlUp).Offset(1, 0) = M
End If
M = ListBox28.Value
If Application.CountIf(Range("A39:A45"), "=" & M) = 0 Then
Range("A83").End(xlUp).Offset(1, 0) = M
End If
M = ListBox29.Value
If Application.CountIf(Range("A39:A45"), "=" & M) = 0 Then
Range("A83").End(xlUp).Offset(1, 0) = M
End If
M = ListBox30.Value
If Application.CountIf(Range("A39:A45"), "=" & M) = 0 Then
Range("A83").End(xlUp).Offset(1, 0) = M
End If
M = ListBox31.Value
If Application.CountIf(Range("A39:A45"), "=" & M) = 0 Then
Range("A83").End(xlUp).Offset(1, 0) = M
End If
M = ListBox32.Value
If Application.CountIf(Range("A39:A45"), "=" & M) = 0 Then
Range("A83").End(xlUp).Offset(1, 0) = M
End If
M = ListBox33.Value
If Application.CountIf(Range("A39:A45"), "=" & M) = 0 Then
Range("A83").End(xlUp).Offset(1, 0) = M
End If
M = ListBox34.Value
If Application.CountIf(Range("A39:A45"), "=" & M) = 0 Then
Range("A83").End(xlUp).Offset(1, 0) = M
End If

Dim F
F = ListBox17.Value
If Application.CountIf(Range("A39:A45"), "=" & F) = 0 Then
Range("A128").End(xlUp).Offset(1, 0) = F
End If
F = ListBox18.Value
If Application.CountIf(Range("A39:A45"), "=" & F) = 0 Then
Range("A128").End(xlUp).Offset(1, 0) = F
End If
F = ListBox19.Value
If Application.CountIf(Range("A39:A45"), "=" & F) = 0 Then
Range("A128").End(xlUp).Offset(1, 0) = F
End If
F = ListBox20.Value
If Application.CountIf(Range("A39:A45"), "=" & F) = 0 Then
Range("A128").End(xlUp).Offset(1, 0) = F
End If
F = ListBox21.Value
If Application.CountIf(Range("A39:A45"), "=" & F) = 0 Then
Range("A128").End(xlUp).Offset(1, 0) = F
End If
F = ListBox22.Value
If Application.CountIf(Range("A39:A45"), "=" & F) = 0 Then
Range("A128").End(xlUp).Offset(1, 0) = F
End If
F = ListBox23.Value
If Application.CountIf(Range("A39:A45"), "=" & F) = 0 Then
Range("A128").End(xlUp).Offset(1, 0) = F
End If
F = ListBox24.Value
If Application.CountIf(Range("A39:A45"), "=" & F) = 0 Then
Range("A128").End(xlUp).Offset(1, 0) = F
End If
F = ListBox25.Value
If Application.CountIf(Range("A39:A45"), "=" & F) = 0 Then
Range("A128").End(xlUp).Offset(1, 0) = F
End If
F = ListBox26.Value
If Application.CountIf(Range("A39:A45"), "=" & F) = 0 Then
Range("A128").End(xlUp).Offset(1, 0) = F
End If
Dim W As String
Dim K As String
Dim P As String
Dim Début As Date
Dim J As Double
Dim F As Date
Dim compteur As Double
Dim x As Range
Dim Ligne
Dim Colonne
Début = DTPicker1.Value
Dim Valeur As Double

For i = 6 To 36
 Durée = TextBox113.Value
If Range("D" & i) = "" And _
       Range("D" & i - 1) <> "" Then
    J = 0
    J = (Durée.Value * 2)
    Ligne = 5
    Colonne = Application.Match(Me.DTPicker1 * 1, Rows(5))
    If Me.ToggleButton1 = False Then
    ActiveSheet.Cells(Ligne, Colonne).Offset(i - 6, 0) = 1
    End If
    
    If Me.ToggleButton1 = True Then
    ActiveSheet.Cells(Ligne, Colonne).Offset(i - 6, 1).Select
    ActiveCell.Offset(0, -1) = 1
    End If
    
    If Durée = 0.5 Then
        Range("ZZ" & i - 1).End(xlToLeft).Select
Dim rng As Range: Set rng = Selection
 With rng
 .Interior.Color = showcolor
 .Font.Color = showcolor
 End With
        Exit Sub
End If

    If i = 6 Or Durée <= 2 Then
     compteur = 1
     End If
     If i > 6 And Durée > 2 And Me.ToggleButton1 = True Or Me.ToggleButton1 = False Then
     compteur = 2
     End If
     
     If Me.ToggleButton1 = True And Durée <= 2 Then
     compteur = 1
     End If
     
    While compteur < J
        compteur = compteur + 1
        F = Range("ZZ" & i - 1).End(xlToLeft).Offset(-1 * (i - 6), 0)
        P = Range("ZZ" & i - 1).End(xlToLeft).Offset(-1 * (i - 6), 7)
        Range("ZZ" & i - 1).End(xlToLeft).Offset(0, 1) = 1
        W = WeekdayName(Weekday(F))
        K = WeekdayName(Weekday(F))
        
        If W = "samedi" And compteur < J Then
            Range("zz" & i - 1).End(xlToLeft).Select
            Range(ActiveCell, ActiveCell.End(xlToLeft)).Select

 Set rng = Selection
 With rng
 .Interior.Color = showcolor
 .Font.Color = showcolor
 End With
         
            MsgBox "La tâche n'est pas achevée !", vbOKOnly
            If Range("ZZ" & i - 1).End(xlToLeft).Offset(-1 * (i - 6), 5).Interior.Color = 255 Then
            Range("ZZ" & i - 1).End(xlToLeft).Offset(0, 7) = 1
            End If
            Range("ZZ" & i - 1).End(xlToLeft).Offset(0, 5) = 1
        End If
        If W = "samedi" And compteur = J Then
            Range("zz" & i - 1).End(xlToLeft).Select
            Range(ActiveCell, ActiveCell.End(xlToLeft)).Select
            Set rng = Selection
 With rng
 .Interior.Color = showcolor
 .Font.Color = showcolor
 End With
            Exit Sub
        End If
        Range("ZZ" & i - 1).End(xlToLeft).Offset(0, 1).Select
        If ActiveCell.Interior.Color = 255 And compteur < J Then
            Range("zz" & i - 1).End(xlToLeft).Select
            Range(ActiveCell, ActiveCell.End(xlToLeft)).Select
           Set rng = Selection
 With rng
 .Interior.Color = showcolor
 .Font.Color = showcolor
 End With
            MsgBox "La tâche n'est pas achevée !", vbOKOnly
            Range("ZZ" & i - 1).End(xlToLeft).Offset(0, 3) = 1
        End If
         If ActiveCell.Interior.Color = 255 And W = "vendredi" And compteur < J Then
         Range("zz" & i - 1).End(xlToLeft).Select
            Range(ActiveCell, ActiveCell.End(xlToLeft)).Select
            Set rng = Selection
 With rng
 .Interior.Color = showcolor
 .Font.Color = showcolor
 End With
            MsgBox "La tâche n'est pas achevée !", vbOKOnly
            Range("ZZ" & i - 1).End(xlToLeft).Offset(0, 7) = 1
            End If
            
         If ActiveCell.Interior.Color = 255 And W = "jeudi" And compteur < J Then
         Pont = MsgBox("Jeudi Férié ! Voulez-Vous faire le Pont?" & vbYesNo)
         If Pont = vbYes Then
         Range("zz" & i - 1).End(xlToLeft).Select
            Range(ActiveCell, ActiveCell.End(xlToLeft)).Select
            Set rng = Selection
 With rng
 .Interior.Color = showcolor
 .Font.Color = showcolor
 End With
            MsgBox "La tâche n'est pas achevée !", vbOKOnly
            Range("ZZ" & i - 1).End(xlToLeft).Offset(0, 9) = 1
            End If
          If Pont = vbNo Then
         Range("zz" & i - 1).End(xlToLeft).Select
            Range(ActiveCell, ActiveCell.End(xlToLeft)).Select
             Set rng = Selection
 With rng
 .Interior.Color = showcolor
 .Font.Color = showcolor
 End With
            MsgBox "La tâche n'est pas achevée !", vbOKOnly
            Range("ZZ" & i - 1).End(xlToLeft).Offset(0, 3) = 1
            End If
           End If
            
        Range("ZZ" & i - 1).End(xlToLeft).Offset(0, 7).Select
        If ActiveCell.Interior.Color = 255 And K = "mardi" And compteur < J Then
         Pont = MsgBox("Mardi Férié ! Voulez-Vous faire le Pont?" & vbYesNo)
         If Pont = vbYes Then
         Range("zz" & i - 1).End(xlToLeft).Select
            Range(ActiveCell, ActiveCell.End(xlToLeft)).Select
             Set rng = Selection
 With rng
 .Interior.Color = showcolor
 .Font.Color = showcolor
 End With
            MsgBox "La tâche n'est pas achevée !", vbOKOnly
            Range("ZZ" & i - 1).End(xlToLeft).Offset(0, 9) = 1
            End If
          If Pont = vbNo Then
         Range("zz" & i - 1).End(xlToLeft).Select
            Range(ActiveCell, ActiveCell.End(xlToLeft)).Select
            Set rng = Selection
 With rng
 .Interior.Color = showcolor
 .Font.Color = showcolor
 End With
            MsgBox "La tâche n'est pas achevée !", vbOKOnly
            Range("ZZ" & i - 1).End(xlToLeft).Offset(0, 5) = 1
            End If
            End If
         
        If ActiveCell.Interior.Color = 255 And compteur = J Then
        Range("zz" & i - 1).End(xlToLeft).Select
            Range(ActiveCell, ActiveCell.End(xlToLeft)).Select
            Set rng = Selection
 With rng
 .Interior.Color = showcolor
 .Font.Color = showcolor
 End With
            End If
    Wend
    Range("zz" & i - 1).End(xlToLeft).Select
    Range(ActiveCell, ActiveCell.End(xlToLeft)).Select
    Set rng = Selection
 With rng
 .Interior.Color = showcolor
 .Font.Color = showcolor
 End With
End If
Next i
End With
Exit Sub
ETIQUETTE: Erreur = ("Erreur, Vérifier les données" & vbOKOnly)
End Sub
 

JNP

XLDnaute Barbatruc
Re : Condition qui s'exécute même fausse

Re :),
Dès fois que tu en ai besoin plus tard, un petit exemple avec une ListBox à choix multiple et une simple :p
Bonne suite :cool:
 

Pièces jointes

  • Exemple listbox.xls
    33 KB · Affichages: 34
  • Exemple listbox.xls
    33 KB · Affichages: 38
  • Exemple listbox.xls
    33 KB · Affichages: 35

Bebere

XLDnaute Barbatruc
Re : Condition qui s'exécute même fausse

bonjour dmoluc,JNP,le forum
code pour userform5

Code:
Private Sub UserForm_Initialize()
    Dim rng As Range, Ligne As Long, Colonne As Integer, D As Double

'    ActiveSheet.Unprotect

    TextBox139.Value = "prix"
    TextBox141.Value = "prix"
    TextBox138.Value = "Nbr."
    TextBox140.Value = "Nbr."
    Call choix(ToggleButton1)
    Call choit(ToggleButton2)
   

    With Sheets("Caractéristiques des matériaux")
        Set rng = .Range("A2:A" & .Range("A500").End(xlUp).Row)
    End With

    ListBox1.List = rng.Value
    ListBox3.List = rng.Value
    ListBox4.List = rng.Value
    ListBox5.List = rng.Value
    ListBox7.List = rng.Value
    ListBox9.List = rng.Value

    With Sheets("matériels")
        ListBox2.List = .Range("H2:H" & .Range("H500").End(xlUp).Row).Value
        ListBox8.List = .Range("K2:K" & .Range("K500").End(xlUp).Row).Value
        Set rng = .Range("A2:A" & .Range("A500").End(xlUp).Row)
    End With

    For i = 27 To 34
        Me("ListBox" & i).List = rng.Value
    Next

    With Sheets("BULL")
        ListBox6.List = .Range("W2:W" & .Range("W500").End(xlUp).Row).Value
    End With

    With Sheets("Métré et Tâches")
        ListBox10.List = .Range("A2:A" & .Range("A500").End(xlUp).Row).Value
    End With

    With Sheets("personnels")
        Set rng = .Range("A2:A" & .Range("A500").End(xlUp).Row)
    End With

    For i = 11 To 16
        Me("ListBox" & i).List = rng.Value
    Next

    With Sheets("fournitures")
        Set rng = .Range("A2:A" & .Range("A500").End(xlUp).Row)
    End With

    For i = 17 To 26
        Me("ListBox" & i).List = rng.Value
    Next

    With Sheets("Métré et Tâches")
        ListBox35.List = .Range("I2:I" & .Range("I500").End(xlUp).Row).Value
    End With

    With Sheets("Programme des travaux")
        L = .Range("A36").End(xlUp).Row
        If L > 6 Then
            ListBox10.Value = .Range("A" & L).Value
        Else
            DTPicker1.Value = .Range("AR2").Value
        End If
        TextBox142.Value = .Range("A170").Value
    End With

    If Sheets("Programme des travaux").Range("A6") <> "" Then
        Ligne = 16
        D = Year(Me.DTPicker1)
        With Sheets("feuil1")
            Colonne = .Range("B1:zz1").Find(D, LookIn:=xlValues, lookat:=xlWhole).Column
            If .Cells(Ligne, Colonne).Value <> "" Then
                Me.DTPicker1.Value = .Cells(Ligne, Colonne).Value
            Else
                Me.DTPicker1.Value = Sheets("Programme des travaux").Range("AR2").Value
            End If
            Me.DTPicker2.Value = Me.DTPicker1.Value
        End With
    End If

End Sub
 
Dernière édition:

dmoluc

XLDnaute Occasionnel
Re : Condition qui s'exécute même fausse

Bonjour JNP, et Bonjour à tous

Merci pour le petit fichier avec les listBox je vais certainement en tirer parti
Pour Beber je mets le fichier en version 2003 mais il y aura pas mal de perte de fidélité car certaine formule ont bien plus de 7 si imbriqués

http://cjoint.com/?3HniqOKXWYx

Je vais essayer de finir le code du bouton en espérant ne pas dépasser la capacité de la procédure et quand j'aurai terminer je ne manquerais pas de mettre le fichier en ligne ; si ça peu servir à quelqu'un ce sera super

Cordialement

A+
 

dmoluc

XLDnaute Occasionnel
Re : Condition qui s'exécute même fausse

Merci Beber pour cette version du code de l'UserForm5 beaucoup plus professionnelle que la mienne, que je ne vais pas simplement remplacer par celle-ci, mais essayer de comprendre comment fonctionnes les boucles.
Encore merci et A +
 

dmoluc

XLDnaute Occasionnel
Re : Condition qui s'exécute même fausse

J'ai encore une diablerie dans le code d'un bouton :mad:
A la fin de la procédure j'ai fait des erreur de frappe et de syntaxe et quand je les répares, cela bloque le l'ouverture de l'userForm, et même si j'annule les modifications L'userForm reste bloquer
Voilà le code du bouton calculer de l'onglet transport si quelqu'un pouvait m'expliquer ce qui ce passe

Code:
Private Sub CommandButton2_Click()
On Error GoTo ETIQUETTE
Dim Tps As Double
Tps = ((TextBox23.Value * 60 / TextBox10.Value) + (TextBox23.Value * 60 / TextBox11.Value))
If TextBox11 <> "" And TextBox10 = "" Then
TextBox81.Value = "Pelle"
TextBox10.Value = TextBox11.Value
End If
If TextBox10 <> "" And TextBox11 = "" Then
TextBox11.Value = TextBox10.Value
End If
If TextBox13.Value = "" Then
TextBox13.Value = 0
End If

If TextBox2 <> "" Then
TextBox81.Value = "Pelle"
If Me.ToggleButton1 = True And TextBox2 <> "" Then
TextBox21 = ((TextBox14.Value / (godet.Value * coef.Value)) * cycle.Value)
End If
If ToggleBouton1 = False And TextBox2 <> "" Then
TextBox21 = (TextBox14.Value * 60 / TextBox8.Value)

End If
Durée = (Tps + TextBox9.Value + TextBox13.Value + TextBox21.Value)
TextBox20.Value = Int(Round((Durée / TextBox21.Value) + 0.5))
TextBox19.Value = Int(Round((Durée / TextBox21.Value) - 0.5))
TextBox17.Value = TextBox2.Value
TextBox16.Value = (TextBox2.Value * TextBox19.Value / (Durée / TextBox21.Value))
TextBox12.Value = (TextBox17.Value * TextBox6)
TextBox18.Value = (TextBox16.Value * TextBox6)
End If

If TextBox28 <> "" Then
TextBox81.Value = "Chargeur"
Dim God As Double
If TextBox13.Value = "" Then
TextBox13.Value = 0
Dim Nbgr As Variant, Nbg As Variant
End If
If Me.ToggleButton1 = False And TextBox28 <> "" Then
God = (TextBox15.Value / (TextBox26.Value * TextBox29.Value * TextBox31.Value))
Nbg = Int(Round(God + 0.5))
TextBox21.Value = ((TextBox25 * Nbg) * (60 / TextBox24.Value))
TextBox18.Value = ((TextBox24.Value / TextBox21) * TextBox15.Value)
D = CDbl(TextBox21.Value) + CDbl(TextBox13.Value) + CDbl(TextBox9.Value) + Tps
TextBox20.Value = Int(Round((D / TextBox21.Value) + 0.5))
TextBox19.Value = Int(Round((D / TextBox21.Value) - 0.5))
TextBox12.Value = (TextBox18.Value * TextBox19.Value / (D / TextBox21.Value))
TextBox17.Value = (TextBox18.Value / TextBox31)
TextBox16.Value = (TextBox12.Value / TextBox31)
End If


If Me.ToggleButton1 = True And TextBox28 <> "" Then

God = (TextBox14.Value / (TextBox26.Value * TextBox27Value))
TextBox21.Value = (TextBox25.Value * Int(Round(God + 0.5)))
TextBox18.Value = ((TextBox24.Value / TextBox21) * TextBox15.Value)
D = CDbl(TextBox21.Value) + CDbl(TextBox13.Value) + CDbl(TextBox9.Value) + Tps
TextBox20.Value = Int(Round((D / TextBox21.Value) + 0.5))
TextBox19.Value = Int(Round((D / TextBox21.Value) - 0.5))
TextBox12.Value = (TextBox18.Value * TextBox19.Value / (D / TextBox21.Value))
TextBox17.Value = (TextBox18.Value / TextBox31)
TextBox16.Value = (TextBox12.Value / TextBox31)
End If
End If

If TextBox45 <> "" Then
TextBox81.Value = "Finisseur"
D = CDbl(TextBox21.Value) + CDbl(TextBox13.Value) + CDbl(TextBox9.Value) + Tps
If CDbl(TextBox21.Value) >= CDbl(TextBox9.Value) Then
TextBox20.Value = Int(Round((D / CDbl(TextBox21.Value)) + 0.5))
TextBox19.Value = Int(Round((D / CDbl(TextBox21.Value)) - 0.5))
TextBox18Value = TextBox45.Value
TextBox12Value = (CDbl(TextBox45.Value) * CDbl(TextBox19.Value) / (D / CDbl(TextBox21.Value)))
End If
If CDbl(TextBox21.Value) < CDbl(TextBox9.Value) Then
TextBox20.Value = Int(Round((D / CDbl(TextBox9.Value)) + 0.5))
TextBox19.Value = Int(Round((D / CDbl(TextBox9.Value)) - 0.5))
TextBox18Value = CDbl(TextBox79.Value)
TextBox12Value = (CDbl(TextBox45.Value) * CDbl(TextBox19.Value) / (D / CDbl(TextBox9.Value)))
End If
End If

If TextBox62 <> "" Then
TextBox81.Value = "Raboteuse"
D = CDbl(TextBox21.Value) + CDbl(TextBox13.Value) + CDbl(TextBox9.Value) + Tps
TextBox20.Value = Int(Round((D / CDbl(TextBox21.Value)) + 0.5))
TextBox19.Value = Int(Round((D / CDbl(TextBox21.Value)) - 0.5))
TextBox18.Value = TextBox63.Value
TextBox12.Value = (CDbl(TextBox63.Value) * CDbl(TextBox19.Value) / (D / CDbl(TextBox21.Value)))
TextBox17.Value = (CDbl(TextBox18.Value) / CDbl(TextBox60))
TextBox16.Value = (CDbl(TextBox12.Value) / CDbl(TextBox60))
End If

If TextBox80.Value = "" Then
TextBox80.Value = 8
End If

If Me.OptionButton1 = True And Me.ToggleButton1 = True Then
TextBox83.Value = TextBox20.Value
TextBox82Value = ListeBox2Imputation.ListIndex
TextBox85.Value = (CDbl(TextBox17.Value) * CDbl(TextBox80.Value))

End If

If Me.OptionButton1 = True And Me.ToggleButton1 = False Then
TextBox83.Value = TextBox20.Value
TextBox82Value = ListeBox2Imputation.ListIndex
TextBox85.Value = (CDbl(TextBox18.Value) * CDbl(TextBox80.Value))

End If

If Me.OptionButton2 = True And Me.ToggleButton1 = True Then
TextBox83.Value = TextBox19.Value
TextBox82Value = ListeBox2Imputation.ListIndex
TextBox85 = (CDbl(TextBox16.Value) * CDbl(TextBox80.Value))

End If

If Me.OptionButton2 = True And Me.ToggleButton1 = False Then
TextBox83.Value = TextBox19.Value
TextBox82Value = ListeBox2Imputation.ListIndex
TextBox85.Value = (CDbl(TextBox12.Value) * CDbl(TextBox80.Value))

End If

Exit Sub
ETIQUETTE: erreur = MsgBox("Il manque des données pour effectuer le calcul" & vbOKOnly)
End Sub

Voilà comment je corrige le code

Code:
If Me.OptionButton1 = True And Me.ToggleButton1 = True Then
TextBox83.Value = TextBox20.Value
TextBox82.Value = ListBox2.value
TextBox85.Value = (CDbl(TextBox17.Value) * CDbl(TextBox80.Value))

End If

If Me.OptionButton1 = True And Me.ToggleButton1 = False Then
TextBox83.Value = TextBox20.Value
TextBox82.Value = ListBox2value
TextBox85.Value = (CDbl(TextBox18.Value) * CDbl(TextBox80.Value))

End If

If Me.OptionButton2 = True And Me.ToggleButton1 = True Then
TextBox83.Value = TextBox19.Value
TextBox82.Value = ListBox2.value
TextBox85 = (CDbl(TextBox16.Value) * CDbl(TextBox80.Value))

End If

If Me.OptionButton2 = True And Me.ToggleButton1 = False Then
TextBox83.Value = TextBox19.Value
'Il Manquait le point et listebox une grosse faute de frappe
TextBox82.Value = ListBox2.Value
TextBox85.Value = (CDbl(TextBox12.Value) * CDbl(TextBox80.Value))

End If

Est-ce la procédure qui devient trop longue une fois corrigée ? Normalement le code devrait fonctionnait, d'autant plus qu'il marchait avant mis à part les quelques lignes de la fin


Si quelqu'un a une idée, merci d'avance

Cordialement

Didier
 

dmoluc

XLDnaute Occasionnel
Re : Condition qui s'exécute même fausse

complètement impossible de modifier la moindre ligne du bouton sans bloquer l'UserForm, comme d'habitude et même plus je n'y comprend vraiment rien


Faut-il que je reprenne la procédure depuis le début ?
 

Discussions similaires

Réponses
2
Affichages
147

Statistiques des forums

Discussions
312 196
Messages
2 086 099
Membres
103 116
dernier inscrit
kutobi87