Alimenter textbox via combobox sur la feuile 2

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

Re : Alimenter textbox via combobox sur la feuile 2

Bonjour.
Comme ça:
VB:
Private Sub ComboBox1_Change()
Dim L As Long
L = ComboBox1.ListIndex + 5
With Sheets("Clients")
   Me.TextBox1 = .Cells(L, 4).Text 'Adresse
   Me.TextBox2 = .Cells(L, 5).Text 'CP
   Me.TextBox3 = .Cells(L, 6).Text 'Ville
   Me.TextBox4 = .Cells(L, 7).Text 'Tel
   Me.TextBox5 = .Cells(L, 8).Text 'Fax
   Me.TextBox6 = .Cells(L, 9).Text 'Mobile
   Me.TextBox7 = .Cells(L, 10).Text 'Email
   End With
End Sub
Cordialement
 
Re : Alimenter textbox via combobox sur la feuile 2

Bonjour max,

reprends ces codes
Code:
Private Sub UserForm_Initialize()
    Dim aa As Variant
    aa = Feuil2.Range("C4:C" & Feuil2.Range("C65536").End(xlUp).Row)
    ComboBox1.List = aa
 
End Sub
'Recherche par la combobox
Private Sub ComboBox1_Change()
Dim C As Range
  With Sheets("Clients")
  
         Me.TextBox1 = .Cells(ComboBox1.ListIndex + 5, 4).Text 'Adresse
        Me.TextBox2 = .Cells(ComboBox1.ListIndex + 5, 5).Text 'CP
       Me.TextBox3 = .Cells(ComboBox1.ListIndex + 5, 6).Text 'Ville
      Me.TextBox4 = .Cells(ComboBox1.ListIndex + 5, 7).Text 'Tel
     Me.TextBox5 = .Cells(ComboBox1.ListIndex + 5, 8).Text 'Fax
    Me.TextBox6 = .Cells(ComboBox1.ListIndex + 5, 9).Text 'Mobile
   Me.TextBox7 = .Cells(ComboBox1.ListIndex + 5, 10).Text 'Email

End With
End Sub
à+
Philippe

Édit: Bonjour Dranreb
 
Re : Alimenter textbox via combobox sur la feuile 2

Re,

je reviens avec une petite modif car dans ton code tu alimentes le combobox à partir de C5 alors que les données commencent en C4
Code:
Private Sub UserForm_Initialize()
    Dim aa As Variant
    aa = Feuil2.Range("C4:C" & Feuil2.Range("C65536").End(xlUp).Row)
    ComboBox1.List = aa
 
End Sub

'Recherche par la combobox
Private Sub ComboBox1_Change()
Dim C As Range
  With Sheets("Clients")
  
         Me.TextBox1 = .Cells(ComboBox1.ListIndex + 4, 4).Text 'Adresse
        Me.TextBox2 = .Cells(ComboBox1.ListIndex + 4, 5).Text 'CP
       Me.TextBox3 = .Cells(ComboBox1.ListIndex + 4, 6).Text 'Ville
      Me.TextBox4 = .Cells(ComboBox1.ListIndex + 4, 7).Text 'Tel
     Me.TextBox5 = .Cells(ComboBox1.ListIndex + 4, 8).Text 'Fax
    Me.TextBox6 = .Cells(ComboBox1.ListIndex + 4, 9).Text 'Mobile
   Me.TextBox7 = .Cells(ComboBox1.ListIndex + 4, 10).Text 'Email

End With
End Sub
à+
Philippe
 
- 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
17
Affichages
933
Réponses
17
Affichages
880
Réponses
2
Affichages
87
Réponses
1
Affichages
223
Réponses
40
Affichages
1 K
Réponses
5
Affichages
193
Retour