Microsoft 365 Adapter un code (saisies de TextBox)

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

Arthur EXL

XLDnaute Nouveau
Bonjour,

Voici le fichier.
Mon problème est que je souhaite pouvoir entre tu texte (tout caractères) dans le textbox "observations"
Actuellement je peux rentrer que des nombres pour tous les textbox

Cdlt
 

Pièces jointes

  • TS_dessus_24.xlsm
    46.2 KB · Affichages: 9

youky(BJ)

XLDnaute Barbatruc
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:

Statistiques des forums

Discussions
311 721
Messages
2 081 928
Membres
101 842
dernier inscrit
seb0390