Probleme de ComboBox...

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 :eek:
 

Hulk

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

skoobi

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

Hulk

XLDnaute Barbatruc
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 :D
 
Dernière édition:

Discussions similaires

Réponses
11
Affichages
347
Réponses
6
Affichages
286

Statistiques des forums

Discussions
312 495
Messages
2 088 964
Membres
103 992
dernier inscrit
Christine 974