Format TextBox + effacer données

thespeedy20

XLDnaute Occasionnel
Bonjour à tous,

J'ai plusieurs textbox, et j'aimerais leur ajouter un format:
ex Age= an; taille en M; Poids en kg.

La 2ème chose, j'aimerais effacer toutes les données à l'aide d'une macro

Merci d'avance pour la marche à suivre.

Ci-joint le fichier

Oli
 

Pièces jointes

  • test.zip
    16.9 KB · Affichages: 29
  • test.zip
    16.9 KB · Affichages: 31
  • test.zip
    16.9 KB · Affichages: 26

Dull

XLDnaute Barbatruc
Re : Format TextBox + effacer données

Salut thespeedy20, le Forum

Un essai en Pièce Jointe avec ce que j'ai compris

Code:
[COLOR=BLUE]Private Sub[/COLOR] CommandButton1_Click()
[COLOR=BLUE]Dim[/COLOR] i [COLOR=BLUE]As Byte[/COLOR], Derlig [COLOR=BLUE]As Long[/COLOR]
    [COLOR=BLUE]With[/COLOR] Sheets("données")
    Derlig = .Range("C65536").End(xlUp).Row + 1
        .Range("C" & Derlig) = IIf(TextBox3.Value >= 2, TextBox3.Value & " ans", TextBox3.Value & " an")
        .Range("D" & Derlig) = TextBox4.Value & " m"
        .Range("E" & Derlig) = TextBox5.Value & " Kg"
        .Range("F" & Derlig) = TextBox6.Value
    [COLOR=BLUE]End With[/COLOR]
[COLOR=BLUE]For[/COLOR] i = 3 [COLOR=BLUE]To[/COLOR] 6
    OLEObjects("TextBox" & i).Object.Value = ""
[COLOR=BLUE]Next[/COLOR] i
[COLOR=BLUE]End Sub[/COLOR]
Bonne Journée
 

Pièces jointes

  • blicq.xls
    47.5 KB · Affichages: 47

Dull

XLDnaute Barbatruc
Re : Format TextBox + effacer données

Salut Oli, Re Pierrot:), le Forum

CasseG... les TextBoxes sur la Feuille c'est pas trop ma tasse de thé et la seule solution que j'ai pu trouver c'est en Appuyant sur la touche Echap.

teste le Fichier ci-Joint. Mais je te conseil de passer Par un UserForm C'est beaucoup plus pratique;).

Bonne Journée
 

Pièces jointes

  • blicq-2.xls
    46.5 KB · Affichages: 43

Pierrot93

XLDnaute Barbatruc
Re : Format TextBox + effacer données

Re,

on peut également utiliser l'événement "KeyUp" :

Code:
Private Sub TextBox3_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
    If KeyCode = 9 Then If Shift Then TextBox2.Activate Else TextBox4.Activate
End Sub
@+
 

Discussions similaires

Membres actuellement en ligne

Statistiques des forums

Discussions
312 247
Messages
2 086 590
Membres
103 247
dernier inscrit
bottxok