Probleme de ComboBox...

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

nikon72

XLDnaute Nouveau
Bonsoir à tous,

voila mon probleme, j ai créé un USF avec un ComboBox et 5 TextBox,

J aimerai que quand je choisi un nombre dans ma combobox, il m affiche les autre cellule dans les textbox, mais voila, ca n affiche rien....

je cal un peu...

j ai deja cherché un peu (bcp..) sur le forum, mais je bloque sur la fait de prendre les donnees sur une autre page je pense...

voila mon code,

Private Sub UserForm2_Initialize()

With Sheets("ORIGINAL")
For i = 2 To .[D65536].End(xlUp).Row
If .Cells(i, 1) <> .Cells(i - 1, 1) Then
ComboBox1.AddItem .Cells(i, 1).Value
End If
Next
End With

End Sub


Private Sub ComboBox1_Change()

Dim lign As Long

If UserForm2.ComboBox1 <> "" Then
lign = UserForm2.ComboBox1.ListIndex + 2
UserForm2.TextBox1 = Sheets("ORIGINAL").Range("A" & lign).Value
UserForm2.TextBox2 = Sheets("ORIGINAL").Range("F" & lign).Value
UserForm2.TextBox3 = Sheets("ORIGINAL").Range("G" & lign).Value
UserForm2.TextBox4 = Sheets("ORIGINAL").Range("H" & lign).Value
UserForm2.TextBox5 = Sheets("ORIGINAL").Range("I" & lign).Value

End If

End Sub

si quelqu un peu m aidé...


Merci 😱
 
Re : Probleme de ComboBox...

Hello,

Apparement c'et ici
Code:
With Sheets("ORIGINAL")
For i = 2 To .[D65536].End(xlUp).Row
If .Cells(i, 1) <> .Cells(i - 1, 1) Then
ComboBox1.AddItem .Cells(i, 1).Value
End If
Next
End With
Remplace par
Code:
With Sheets("ORIGINAL")
For i = 2 To .[D65536].End(xlUp).Row
If .Cells(i, [COLOR="Red"][B]4[/B][/COLOR]) <> .Cells(i - 1, [COLOR="red"][B]4[/B][/COLOR]) Then
ComboBox1.AddItem .Cells(i, [COLOR="red"][B]4[/B][/COLOR]).Value
End If
Next
End With
4 étant la quatrième colonne, à savoir la colonne D.

Cdt, Hulk.
 
Re : Probleme de ComboBox...

Re,

Tout d'abord, quel que soit le nom d'un userform, l'événement Initialise s'écrit toujours:
Code:
Private Sub UserForm_Initialize()
sans le "2".
Ensuite, je suppose que tu récupères la colonne D:
Code:
Private Sub UserForm_Initialize()
    With Sheets("ORIGINAL")
        For i = 2 To .[D65536].End(xlUp).Row
            If .Cells(i, [COLOR=Blue][B]4[/B][/COLOR]) <> .Cells(i - 1, [B][COLOR=Blue]4[/COLOR][/B]) Then
                ComboBox1.AddItem .Cells(i, [B][COLOR=Blue]4[/COLOR][/B]).Value
            End If
        Next
    End With

End Sub
Sinon, le code du combobox est bon 😉.

Edit: bonsoir hulk
 
Re : Probleme de ComboBox...

Re,

En le 2 de
Code:
Private Sub UserForm2_Initialize()

Donc
Code:
Private Sub UserForm_Initialize()
    
    
    With Sheets("ORIGINAL")
        For i = [COLOR="Red"][B]3[/B][/COLOR] To .Range("D65000").End(xlUp).Row
            If .Cells(i, 4) <> .Cells(i - 1, 4) Then
                ComboBox1.AddItem .Cells(i, 4).Value
            End If
        Next i
    End With

End Sub
3 parce que ça commence à la ligne 3 !

Cdt, Hulk.

OUPS SALUT SKOOBI...avait pas vu le 2 😀
 
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

Réponses
9
Affichages
256
Réponses
5
Affichages
707
Réponses
4
Affichages
581
Réponses
10
Affichages
533
Réponses
8
Affichages
270
Réponses
3
Affichages
265
Réponses
5
Affichages
312
Retour