XL 2010 Bouton modifier

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

Mimi

XLDnaute Occasionnel
Bonjour à tous,
J'ai créé avec l'aide de ce super forum un petit carnet d'adresse qui jusque là marche bien.
Je voudrais "simplement" ajouter un bouton modifié et là je sèche.
Pouvez-vous me donner un petit coup de main
D'avance merci
Mimi
 

Pièces jointes

bonjour Mimi
je ne me sens pas de pouvoir t'aider comme le ferai l'exellent dranreb 🙂avec ses ckxliées, ce que je vais te donner comme code est juste de forcer l'écriture des numéros de téléphone, fax etc a 10 chiffres
Code:
Private Sub TextBox6_Change()
    Me.TextBox6.Value = Format(Me.TextBox6.Value, "00 00 00 00 00")
End Sub
Private Sub TextBox6_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
    TextBox6.MaxLength = 10
End Sub
Private Sub TextBox7_Change()
    Me.TextBox7.Value = Format(Me.TextBox7.Value, "00 00 00 00 00")
End Sub
Private Sub TextBox7_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
    TextBox7.MaxLength = 10
End Sub
Private Sub TextBox8_Change()
    Me.TextBox8.Value = Format(Me.TextBox8.Value, "00 00 00 00 00")
End Sub
Private Sub TextBox8_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
    TextBox8.MaxLength = 10
End Sub

comme tu l'as déja fait avec ton textbox3
a ce propos tu devrai donner un nom a tes textbox pour savoir qui fait quoi dans le code comme tu l'as fait pour cville
et une indentation serai un plus
bon je te joints le classeur client que dranreb m'a concocter il y a quelque temps🙂
 

Pièces jointes

Bonsoir Mimi, Pascal 🙂

Resultat.TextBox1 = Feuil1.Cells(lig, 1) .Tu dis que tout fonctionne, mais où est-qu'il est le formulaire Resultat??

Pour la combo de recherche, supprime row source.

VB:
Private Sub UserForm_Activate()
ComboBox1 = ""
End Sub

Private Sub UserForm_Initialize()
Dim j As Integer
With Feuil1
For j = 2 To .Range("a65536").End(xlUp).Row
ComboBox1 = .Range("a" & j)
If ComboBox1.ListIndex = -1 Then ComboBox1.AddItem .Range("a" & j)
Next j
End With
End Sub

'Pour le formulaire Saisir

Private Sub UserForm_Initialize()
With ComboBox3
.AddItem "M."
.AddItem "Mme"
.AddItem "Mlle"
.AddItem "M. & Mme"
End With
End Sub
 
Bonjour à tous,
l"exemple de max.lander est bien, le seul souci c'est qu'il supprime la ligne pour la remettre en dessous de la dernière ligne,
Lone-wolf l'userform résultat je ne m'en sert pas j'ai tout réuni sur le même (userform saisir).
En attendant peut-être une autre proposition pour le bouton modifier je vai voir de mon coter.
Merci beaucoup de votre patience
Mimi
 
Bonjour Mimi,

Si tu parle du bouton de modification c'est bizarre. Les modifications s'effectue bien sur la 2ème ligne. De plus pourquoi dans ce cas tu met resultas.TextBox1 dans le formulaire saisir??? 😵 .

Moi j'aurait commencé avec les colonne comme ceci:
N° Corr. - Nom Complet(concatené avec prénom et nom) - Titre (Mme - Mlle -M.) -Prénom - Nom - Adresse - CP - Ville - Tél - Fax - Mail - Site Web - Commentaire. Ensuite dans les propriétés de chaque contrôles à la ligne Tag

´tag.gif

Le 1 correspond à la colonne A - 2 à B - 3 à C etc. Et pour teminer

VB:
Private Sub UserForm_Initialize()
Dim derlig As Integer, x As Integer, ws As Worksheet

Set ws = Sheets("Feuil1")

With ws
For x = 2 To .Range("a65536").End(xlUp).Row
        ComboBox1 = .Range("a" & x)
        If ComboBox1.ListIndex = -1 Then ComboBox1.AddItem .Range("a" & x)
    Next x
    ComboBox1 = ""
End With
End Sub

Private Sub UserForm_Activate()
Me.Top = 100
Me.Left = Me.Left + 288

ComboBox1.Text = ""
TextBox2.SetFocus
End Sub

Private Sub TextBox3_Change() ' Affiche Nom et Prénom
If TextBox3 <> "" Then _
TextBox1 = TextBox2 & " " & TextBox3
End Sub

Private Sub TextBox3_AfterUpdate()
Dim ctrl As Control, i%, j%, col As Range, ws As Worksheet

On Error GoTo fin
Set ws = Sheets("Feuil1")
Set col = ws.Range("A:A")

If TextBox1 <> "" Then
With ws
     i = Application.Match(TextBox1.Text, col, 0)
            If .Cells(i, 1).Value = TextBox1.Value Then
            MsgBox "Le contact est déjà dans la liste.", , "CONTACTS"
    ComboBox1 = ""
For i = 1 To 9
Me.Controls("TextBox" & i) = ""
Next i
Else
Exit Sub
TextBox4.SetFocus
        End If
End With
End If
fin:
Exit Sub
End Sub

Private Sub CmdValider_Click()
Dim ctrl As Control, ws As Worksheet, cel As Range
Dim derlig As Integer, col As Integer, i As Long

Set ws = Sheets("Feuil1")

With ws
derlig = .Range("a65536").End(xlUp).Row + 1

For Each ctrl In Me.Controls
col = Val(ctrl.Tag)
If col > 0 Then
If Not IsNumeric(ctrl) Then
.Cells(derlig, col) = ctrl
Else
.Cells(derlig, col) = CDbl(ctrl)   'format numérique simple ex: 3124
End If
End If
Next ctrl
.Range("G2:H65000").NumberFormat = "000 000 00 00"   'Numéro téléphone et fax
.Range("A:I").Columns.AutoFit
.Range("A2:I65000").Sort [A2], xlAscending
End With

For i = 1 To 9
Me.Controls("TextBox" & i) = ""
Next
TextBox2.SetFocus
End Sub

Private Sub CmdRechercher_Click()
Dim ctrl As Control, i%, j%, col As Range, ws As Worksheet

Set ws = Sheets("Feuil1")
Set col = ws.Range("A:A")

With ws
    i = Application.Match(Me.ComboBox1.Text, col, 0)

    For Each ctrl In Controls
        If ctrl.Tag <> "" Then
            j = Val(ctrl.Tag)
            ctrl.Value = .Cells(i, j).Value
        End If
    Next ctrl
End With
TextBox7 = Format(TextBox7, "000 000 00 00")
TextBox8 = Format(TextBox8, "000 000 00 00")
End Sub

Private Sub CmdModifier_Click()
Dim ctrl As Control, i%, j%, reponse, col As Range, ws As Worksheet

reponse = MsgBox("Voulez-vous vraiment procéder aux modifications ?", vbYesNo, "CONTACTS")

Set ws = Sheets("Feuil1")
Set col = ws.Range("A:A")


If reponse = vbYes Then
With ws
    i = Application.Match(Me.ComboBox1.Text, col, 0)

    For Each ctrl In Controls
        If ctrl.Tag <> "" Then
            j = Val(ctrl.Tag)
            .Cells(i, j).Value = ctrl.Value
        End If
    Next ctrl
End With
Else
ComboBox1 = ""
For i = 1 To 9
Me.Controls("TextBox" & i) = ""
Next i
End If
TextBox2.SetFocus
End Sub

Private Sub CmdQuitter_Click()
ComboBox1 = ""
For i = 1 To 9
Me.Controls("TextBox" & i) = ""
Next i
Unload Me
End Sub
 
Dernière édition:
Re,


il faut enlever + 1 ici: num = Sheets("Recap").Range("A65536").End(xlUp).Row

Supprimer le code du bouton 5 et mettre

num = Sheets("Recap").Range("A65536").End(xlUp).Row 'on part du bas de la colonne, on cherche
Sheets("Recap").Activate
With Sheets("Recap")
.Range("A" & num).Value = TextBox12.Value
.Range("B" & num).Value = ComboBox3.Value
.Range("C" & num).Value = TextBox1.Value
.Range("D" & num).Value = TextBox2.Value
.Range("E" & num).Value = TextBox3.Value
.Range("F" & num).Value = TextBox4.Value
.Range("G" & num).Value = CVille.Value
.Range("H" & num).Value = TextBox6.Value
.Range("I" & num).Value = TextBox7.Value
.Range("J" & num).Value = TextBox8.Value
.Range("K" & num).Value = TextBox9.Value
.Range("L" & num).Value = TextBox10.Value
.Range("M" & num).Value = TextBox11.Value
End With
Unload Saisir

C'est inutile d'appeler une macro quand on peut l'inserer directement dans le bouton.
 
Je ne comprends pas. Tu n'as, pour l'instant, qu' une ligne écrite (ligne 2), comment est-ce possible d'éffacer la ligne 3 si tu n'as rien écrit??? Par-ce que pour inserer une ligne on écrit

Lig = Sheets("Recap").Range("A65536").End(xlUp).Row + 1

Et pour modifier
Lig = Sheets("Recap").Range("A65536").End(xlUp).Row

Donc, elle ne peux pas inserer des lignes.
 
Re Mimi

Sinon comme ceci

VB:
Private Sub CommandButton5_Click()
With Sheets("Recap")
lig = Application.Match(ComboBox1, Columns(1), 0)
.Range("A" & lig).Value = TextBox12.Value
.Range("B" & lig).Value = ComboBox3.Value
.Range("C" & lig).Value = TextBox1.Value
.Range("D" & lig).Value = TextBox2.Value
.Range("E" & lig).Value = TextBox3.Value
.Range("F" & lig).Value = TextBox4.Value
.Range("G" & lig).Value = CVille.Value
.Range("H" & lig).Value = TextBox6.Value
.Range("I" & lig).Value = TextBox7.Value
.Range("J" & lig).Value = TextBox8.Value
.Range("K" & lig).Value = TextBox9.Value
.Range("L" & lig).Value = TextBox10.Value
.Range("M" & lig).Value = TextBox11.Value
End With
Unload Saisir
End Sub
 
- 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
21
Affichages
296
Réponses
6
Affichages
455
Réponses
9
Affichages
227
  • Question Question
Microsoft 365 Catégorisation
Réponses
5
Affichages
594
Retour