Microsoft 365 Adapter un code (saisies de TextBox)

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 !

Arthur EXL

XLDnaute Nouveau
Bonjour,

Je souhaiterai adapter le code suivant afin que je puisse exclure des textbox, exclure j'entend par là que je voudrais pouvoir saisir du texte dans le texbox "TextObservation" uniquement (celui qui est en commentaire).

VB:
Private Sub VALITATION_Click()
'Gérer les copier/coller TextBox vers Cellules "Données"
Dim OK As Boolean, TB As Variant, LR&
OK = True
For Each TB In Me.Controls
    If TypeOf TB Is MSForms.TextBox And Not IsNumeric(TB) Then
        OK = False
        TB.Value = ""
    End If
Next TB
If OK = False Then
    MsgBox "Merci de renseigner des valeurs numériques dans les champs vides", vbCritical
    Else
    With Worksheets("Données")
        LR = .Cells(.Rows.Count, 3).End(xlUp).Row + 1
        .Cells(LR, 3) = Now
        .Cells(LR, 4) = TextJableMax01 * 1
        .Cells(LR, 5) = TextJableMoy01 * 1
        .Cells(LR, 6) = TextJableMin01 * 1
        .Cells(LR, 7) = TextTLMax01 * 1
        .Cells(LR, 8) = TextTLMoy01 * 1
        .Cells(LR, 9) = TextTLMin01 * 1
        .Cells(LR, 10) = TextEpauleMax01 * 1
        .Cells(LR, 11) = TextEpauleMoy01 * 1
        .Cells(LR, 12) = TextEpauleMin01 * 1
        .Cells(LR, 13) = TextJableMax02 * 1
        .Cells(LR, 14) = TextJableMoy02 * 1
        .Cells(LR, 15) = TextJableMin02 * 1
        .Cells(LR, 16) = TextTLMax02 * 1
        .Cells(LR, 17) = TextTLMoy02 * 1
        .Cells(LR, 18) = TextTLMin02 * 1
        .Cells(LR, 19) = TextEpauleMax02 * 1
        .Cells(LR, 20) = TextEpauleMoy02 * 1
        .Cells(LR, 21) = TextEpauleMin02 * 1
        .Cells(LR, 22) = Now
        .Cells(LR, 23) = (TextJableMoy01 * 1 + TextJableMoy02 * 1) / 2
        .Cells(LR, 24) = (TextTLMoy01 * 1 + TextTLMoy02 * 1) / 2
        .Cells(LR, 25) = (TextEpauleMoy01 * 1 + TextEpauleMoy02 * 1) / 2
        .Cells(LR, 26) = TextMini * 1
        .Cells(LR, 27) = TextMaxi * 1
        '.Cells(LR, 28) = TextObservations * 1   
    End With
    MsgBox "Export terminé", vbInformation
    efface
End If

End Sub

Merci par avance pour vos piste,

Cdlt;
 
Solution
Bonjour à tous,
Avant
For Each TB In Me.Controls
If TypeOf TB Is MSForms.TextBox And Not IsNumeric(TB) Then
OK = False
TB.Value = ""
End If
Next TB

APRES
For Each TB In Me.Controls
if TB.name<> "TextObservation" Then
If TypeOf TB Is MSForms.TextBox And Not IsNumeric(TB) Then
OK = False
TB.Value = ""
End If
End If
Next TB

et la suite de la macro
Bruno

EDIT j'ai oublié le s à "TextObservation" le mettre
Bonjour à tous,
Avant
For Each TB In Me.Controls
If TypeOf TB Is MSForms.TextBox And Not IsNumeric(TB) Then
OK = False
TB.Value = ""
End If
Next TB

APRES
For Each TB In Me.Controls
if TB.name<> "TextObservation" Then
If TypeOf TB Is MSForms.TextBox And Not IsNumeric(TB) Then
OK = False
TB.Value = ""
End If
End If
Next TB

et la suite de la macro
Bruno

EDIT j'ai oublié le s à "TextObservation" le mettre
 
Dernière édition:
- 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

Retour