Compare valeure textbox

  • Initiateur de la discussion Initiateur de la discussion popof
  • 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 !

popof

XLDnaute Occasionnel
Bonjour à tous


Petite question, je n'arrive pas à comparer valeur de checkbox à, je m'explique :

Je rentre une valeur dans une checkbox, si la valeur est comprise dans une de mes fourchettes, je mets cette valeurs dans une cellule
exemple qui ne marche pas bien sur 😛

Je clic sur un bouton
Si textbox >0.15 et <0.36 alors
Recopitage dans la cellule D09 de la valeur
Label.caption = résultat cellule D09*2356.03/D...
Reset de tout pour nouvelle valeur

explication limpide non ... :sick:

J'essai de joindre un fichier mais cela va pas être facile du tout

voili voilou
 
Private Sub CommandButton1_Click()
If TextBox1.Value > 0.15 And TextBox1.Value < 0.36 Then
[D9] = TextBox1.Value
...
'et la suite j'ai rien compris à ta demande...

Essaie de joindre le fichier

A+
 
Re le fil,

En fait cela fonctionne, je m'en souvenais plus 😱

Cependant n'y à t'il pas plus simple que le code suivant
Code:
Private Sub CommandButton1_Click()

If TextBox1.Value > '0' And TextBox1.Value < '0.150' Then
Range('e10') = TextBox1.Value
Label4.Caption = Range('g9')
Else
    If TextBox1.Value > '0.151' And TextBox1.Value < '0.353' Then
    Range('e12') = TextBox1.Value
    Label4.Caption = Range('g11')
    Else
        If TextBox1.Value > '00.354' And TextBox1.Value < '0.553' Then
        Range('e14') = TextBox1.Value
        Label4.Caption = Range('g13')
        Else
    If TextBox1.Value > '0.554' And TextBox1.Value < '0.758' Then
    Range('e16') = TextBox1.Value
    Label4.Caption = Range('g15')
    Else
If TextBox1.Value > '0.759' And TextBox1.Value < '0.972' Then
Range('e18') = TextBox1.Value
Label4.Caption = Range('g17')
Else
    If TextBox1.Value > '0.973' And TextBox1.Value < '1.152' Then
    Range('e20') = TextBox1.Value
    Label4.Caption = Range('g19')
    Else
        If TextBox1.Value > '1.153' And TextBox1.Value < '1.352' Then
        Range('e22') = TextBox1.Value
        Label4.Caption = Range('g21')
        Else
    If TextBox1.Value > '1.353' And TextBox1.Value < '1.540' Then
    Range('e24') = TextBox1.Value
    Label4.Caption = Range('g23')
    Else
If TextBox1.Value > '1.541' And TextBox1.Value < '1.749' Then
Range('e26') = TextBox1.Value
Label4.Caption = Range('g25')
Else
    If TextBox1.Value > '1.75' And TextBox1.Value < '1.957' Then
    Range('e28') = TextBox1.Value
    Label4.Caption = Range('g27')
    Else
        If TextBox1.Value > '1.958' And TextBox1.Value < '2.140' Then
        Range('e30') = TextBox1.Value
        Label4.Caption = Range('g29')
        Else
    If TextBox1.Value > '2.141' And TextBox1.Value < '2.346' Then
    Range('e32') = TextBox1.Value
    Label4.Caption = Range('g31')
    Else
If TextBox1.Value > '2.347' And TextBox1.Value < '2.544' Then
Range('e34') = TextBox1.Value
Label4.Caption = Range('g33')
Else
    If TextBox1.Value > '2.545' And TextBox1.Value < '2.749' Then
    Range('e36') = TextBox1.Value
    Label4.Caption = Range('g35')
    Else
        If TextBox1.Value > '2.75' And TextBox1.Value < '2.948' Then
        Range('e38') = TextBox1.Value
        Label4.Caption = Range('g37')
        Else
    If TextBox1.Value > '2.949' And TextBox1.Value < '3.149' Then
    Range('e40') = TextBox1.Value
    Label4.Caption = Range('g39')
    Else
If TextBox1.Value > '3.15' And TextBox1.Value < '3.347' Then
Range('e42') = TextBox1.Value
Label4.Caption = Range('g41')
Else
    If TextBox1.Value > '3.348' And TextBox1.Value < '3.548' Then
    Range('e44') = TextBox1.Value
    Label4.Caption = Range('g43')
    Else
        If TextBox1.Value > '3.549' And TextBox1.Value < '3.743' Then
        Range('e46') = TextBox1.Value
        Label4.Caption = Range('g45')
        Else
    If TextBox1.Value > '3.744' And TextBox1.Value < '3.950' Then
    Range('e48') = TextBox1.Value
    Label4.Caption = Range('g47')
    Else
If TextBox1.Value > '3.951' And TextBox1.Value < '4.153' Then
Range('e50') = TextBox1.Value
Label4.Caption = Range('g49')
Else
    If TextBox1.Value > '4.154' And TextBox1.Value < '4.348' Then
    Range('e52') = TextBox1.Value
    Label4.Caption = Range('g51')
    Else
        If TextBox1.Value > '4.349' And TextBox1.Value < '4.575' Then
        Range('e54') = TextBox1.Value
        Label4.Caption = Range('g53')
        Else
    If TextBox1.Value > '4.576' And TextBox1.Value < '4.752' Then
    Range('e56') = TextBox1.Value
    Label4.Caption = Range('g55')
    Else
If TextBox1.Value > '4.753' And TextBox1.Value < '4.9' Then
Range('e58') = TextBox1.Value
Label4.Caption = Range('g57')
Else
    If TextBox1.Value > '4.901' And TextBox1.Value < '5' Then
    Range('e60') = TextBox1.Value
    Label4.Caption = Range('g59')
    Else
        MsgBox ('Hors echelle de mesure')



End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If


End Sub

Bah oui c long :sick:
 
Bonjour

peut-être comme ceci

Private Sub CommandButton1_Click()

Dim MaLigne As Byte

Select Case Val(TextBox1.Value)
Case Is < 0.15
MaLigne = 10
Case Is < 0.353
MaLigne = 12
Case Is < 0.553
MaLigne = 14
Case Is < 0.758
MaLigne = 16
Case Is < 0.972
MaLigne = 18
Case Is < 1.152
MaLigne = 20
'........ Là tu continues toutes tes valeurs avec MaLigne correspondant à ta ligne de range('E')=textbox1.value
Case Else
MaLigne=0
End select

If MaLigne=0 then
MsgBox ('Hors echelle de mesure')
else
Range('E' & MaLigne) = TextBox1.Value
Label4.Caption = Range('G' & MaLigne -1)
End if

End sub

Bon courage
 
bonjour pascal76 😉

Bah oui forcement ça fait plus pro 😛

Sinon dans la même optique, comment paramètre t'on le format d'une texteboite ?

Car j'ai un petit problème; passé la valeur '10' excel comprends de cette manière :
'10' = '1.00'
'11'='1.100'

Y'a un truc que je lui ais mal expliqué à ce piti excel ? 😱

Mirci
 
re le fil BOBBY, pascal76

C bon avec le code de pascal76 plus di problème dans mes chiffres 🙂
En revanche, toujours pas trouvé comment limité le nombre de chiffre dérière la virgule 😱
Et je n'arrive pas non plus ( bah oui je suis pas doué) à remettre à zero mes textbox et mon 'label4' à l'ouverture du fichier :S

Sinon bah moi ça va 😛

Mirci
 
- 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
13
Affichages
1 K
D
Réponses
9
Affichages
2 K
D
U
Réponses
4
Affichages
6 K
Ukiki
U
F
Réponses
5
Affichages
2 K
Fariri
F
M
Réponses
2
Affichages
2 K
Metalex
M
S
Réponses
6
Affichages
1 K
snipe2004
S
B
Réponses
6
Affichages
14 K
I
Réponses
1
Affichages
1 K
insosama
I
M
Réponses
4
Affichages
4 K
MaximeRoth
M
Retour