Problème de différence en VBA
Bonjour a tous,
Voila j'ai un petit problème que je n'arrive pas a résoudre.
Avec un IF je compare la valeur d'une txt avec la valeur d'une lbl.
Cela fonctionne bien sauf pour les ligne de code en rouge.
Le problème avec les lignes de code en rouge, c'est que des que la valeur de la txt est > ou = a 100 , cela m'affiche directement la msgbox.
Je ne comprend pas pourquoi cela ne fonctionne pas avec ces txt et lbl alors que les autres fonctionnent très bien.
J'ai vérifié les paramètres des lbl et txt ils sont identiques aux autres lbl et txt
Merci d'avance pour votre aide
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
|
Private Sub cmdConf_Click()
Dim O As String
O = cmbChoix.Value
'Déverrouillage Feuille pour execution maccro
With Sheets(O)
.Unprotect Password:="cmms18"
'Verifie que tt les champs sont complet si oui ecris les valeurs dans les cellule adequat de la feuille
Sheets(O).Cells(8, 3).NumberFormat = "dd mmm yyyy"
If txtAf.Text = "" Then
Sheets(O).Cells(10, 3) = lblAf.Caption
Sheets(O).Cells(11, 3) = lblEn.Caption
Else
If txtAf.Text > lblAf.Caption Then
Sheets(O).Cells(10, 3) = txtAf.Text
Sheets(O).Cells(11, 3) = lblEn2.Caption
Else
MsgBox ("Air Frame Time must be superior than original !")
Exit Sub
End If
End If
If O = "FXED" Then
If txtGP.Text = ("") Then
Sheets(O).Cells(10, 8) = lblGP.Caption
Else
'If txtGP.Text > lblGP.Caption Then
Sheets(O).Cells(10, 8) = txtGP.Value
'Else
'MsgBox ("GP Cycle must be superior than original !")
'Exit Sub
'End If
End If
If txtPT.Text = ("") Then
Sheets(O).Cells(11, 8) = lblPT.Caption
Else
If txtPT.Text > lblPT.Caption Then
Sheets(O).Cells(11, 8) = txtPT.Text
Else
MsgBox ("PT Cycle must be superior than original !")
Exit Sub
End If
End If
Else
If txtRin.Text = ("") Then
Sheets(O).Cells(10, 8) = lblRin.Caption
Else
If txtRin.Text > lblRin.Caption Then
Sheets(O).Cells(10, 8) = txtRin.Text
Else
MsgBox ("Rin must be superior than original !")
Exit Sub
End If
End If
If txtN2.Text = ("") Then
Sheets(O).Cells(11, 8) = lblN2.Caption
Else
If txtN2.Text > lblN2.Caption Then
Sheets(O).Cells(11, 8) = txtN2.Text
Else
MsgBox ("N2 must be superior than original !")
Exit Sub
End If
End If
If txtSpray.Text = ("") Then
Sheets(O).Cells(10, 12) = lblSpray.Caption
Else
If txtSpray.Text > lblSpray.Caption Then
Sheets(O).Cells(10, 12) = txtSpray.Text
Else
MsgBox ("Spray Time must be superior than original !")
Exit Sub
End If
End If
End If
If txtHook.Text = ("") Then
Sheets(O).Cells(9, 12) = lblHook.Caption
Else
If txtHook.Text > lblHook.Caption Then
Sheets(O).Cells(9, 12) = txtHook.Text
Else
MsgBox ("Hook Time must be superior than original !")
Exit Sub
End If
End If
If txtCycle.Text = ("") Then
Sheets(O).Cells(9, 8) = lblCycle.Caption
Else
If txtCycle.Text > lblCycle.Caption Then
Sheets(O).Cells(9, 8) = txtCycle.Text
Else
MsgBox ("Cycle must be superior than original !")
Exit Sub
End If
End If
MsgBox ("Update Confirmed")
Sheets(O).Cells(8, 3) = Date
.Protect Password:="cmms18" 'Reverrouillage Feuille après exécution maccro
End With
cmbChoix.Locked = False
End Sub |