Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

Combobox condition avec un autre combobox

5 réponses
Avatar
sleg
BOnjour,

j'ai dans un userform 2 combobox .
mes listes :
- combobox1 un equipe
- combobox2 un profil

et j'aimerais lorsque je selectionne une equipe dans le combobox1 de
n'avoir en selection dans le combobox2 que ce qui concerne le choix du
combobox1.

equipe PRofil
Unix admin
Unix dba
Wintel toto
CA tata
Wintel admin
CA migration

merci de votre aide & bonne journ=E9e

5 réponses

Avatar
DanielCo
Bonjour,
Avec les équipes en colonne A et les profile en colonne B, utilise les
macros suivantes :

Private Sub UserForm_Activate()
Dim c As Range, sh As Worksheet, Dico As Object
Set Dico = CreateObject("scripting.dictionary")
With Sheets("Feuil1")
For Each c In .Range([A2], .Cells(Rows.Count, 1).End(xlUp))
If Not Dico.exists(c.Value) Then
Dico.Add c.Value, c.Value
End If
Next c
Me.ComboBox1.Clear
For Each Item In Dico
Me.ComboBox1.AddItem Item
Next Item
End With
End Sub

Private Sub ComboBox1_Change()
Dim c As Range, sh As Worksheet
Set sh = Sheets("Feuil1")
With Me.ComboBox2
.Clear
For Each c In sh.Range([A2], sh.Cells(Rows.Count, 1).End(xlUp))
If c.Value = Me.ComboBox1.Value Then
Me.ComboBox2.AddItem c.Offset(, 1).Value
End If
Next c
End With
End Sub

Cordialement.
Daniel


BOnjour,

j'ai dans un userform 2 combobox .
mes listes :
- combobox1 un equipe
- combobox2 un profil

et j'aimerais lorsque je selectionne une equipe dans le combobox1 de
n'avoir en selection dans le combobox2 que ce qui concerne le choix du
combobox1.

equipe PRofil
Unix admin
Unix dba
Wintel toto
CA tata
Wintel admin
CA migration

merci de votre aide & bonne journée
Avatar
sleg
BOnjour,

grand merci j'ai un probleme sur la ligne
Next c
Me.ComboBox17
.clear

J'ai utilisation incorrecte de la propriété
.

une idée ?


On 20 avr, 09:51, DanielCo wrote:
Bonjour,
Avec les quipes en colonne A et les profile en colonne B, utilise les
macros suivantes :

Private Sub UserForm_Activate()
    Dim c As Range, sh As Worksheet, Dico As Object
    Set Dico = CreateObject("scripting.dictionary")
    With Sheets("Feuil1")
        For Each c In .Range([A2], .Cells(Rows.Count, 1).End(xlUp ))
            If Not Dico.exists(c.Value) Then
                Dico.Add c.Value, c.Value
            End If
        Next c
        Me.ComboBox1.Clear
        For Each Item In Dico
            Me.ComboBox1.AddItem Item
        Next Item
    End With
End Sub

Private Sub ComboBox1_Change()
    Dim c As Range, sh As Worksheet
    Set sh = Sheets("Feuil1")
    With Me.ComboBox2
        .Clear
        For Each c In sh.Range([A2], sh.Cells(Rows.Count, 1).End( xlUp))
            If c.Value = Me.ComboBox1.Value Then
                Me.ComboBox2.AddItem c.Offset(, 1).Value
            End If
        Next c
    End With
End Sub

Cordialement.
Daniel







> BOnjour,

> j'ai dans un userform 2 combobox .
> mes listes :
> - combobox1 un equipe
> - combobox2 un profil

> et j'aimerais lorsque je selectionne une equipe dans le combobox1 de
> n'avoir en selection dans le combobox2 que ce qui concerne le choix du
> combobox1.

> equipe                   PRofil
> Unix                      admin
> Unix                      dba
> Wintel                   toto
> CA                        tata
> Wintel                   admin
> CA                        migration

> merci de votre aide & bonne journ e
Avatar
sleg
voila le code apres adaptation :

Private Sub UserForm_Activate()
Dim c As Range, sh As Worksheet, Dico As Object
Set Dico = CreateObject("scripting.dictionary")
With Sheets("Liste")
For Each c In .Range([k2], .Cells(Rows.Count, 11).End(xlUp))
If Not Dico.exists(c.Value) Then
Dico.Add c.Value, c.Value
End If
Next c
Me.ComboBox17
.Clear
For Each Item In Dico
Me.ComboBox17.AddItem Item
Next Item
End With
End Sub
Private Sub ComboBox17_Change()
Dim c As Range, sh As Worksheet
Set sh = Sheets("Liste")
With Me.ComboBox15.Clear
For Each c In sh.Range([k2], sh.Cells(Rows.Count,
11).End(xlUp))
If c.Value = Me.ComboBox17.Value Then
Me.ComboBox15.AddItem c.Offset(, 1).Value
End If
Next c
End With
End Sub





On 20 avr, 09:51, DanielCo wrote:
Bonjour,
Avec les quipes en colonne A et les profile en colonne B, utilise les
macros suivantes :

Private Sub UserForm_Activate()
    Dim c As Range, sh As Worksheet, Dico As Object
    Set Dico = CreateObject("scripting.dictionary")
    With Sheets("Feuil1")
        For Each c In .Range([A2], .Cells(Rows.Count, 1).End(xlUp ))
            If Not Dico.exists(c.Value) Then
                Dico.Add c.Value, c.Value
            End If
        Next c
        Me.ComboBox1.Clear
        For Each Item In Dico
            Me.ComboBox1.AddItem Item
        Next Item
    End With
End Sub

Private Sub ComboBox1_Change()
    Dim c As Range, sh As Worksheet
    Set sh = Sheets("Feuil1")
    With Me.ComboBox2
        .Clear
        For Each c In sh.Range([A2], sh.Cells(Rows.Count, 1).End( xlUp))
            If c.Value = Me.ComboBox1.Value Then
                Me.ComboBox2.AddItem c.Offset(, 1).Value
            End If
        Next c
    End With
End Sub

Cordialement.
Daniel







> BOnjour,

> j'ai dans un userform 2 combobox .
> mes listes :
> - combobox1 un equipe
> - combobox2 un profil

> et j'aimerais lorsque je selectionne une equipe dans le combobox1 de
> n'avoir en selection dans le combobox2 que ce qui concerne le choix du
> combobox1.

> equipe                   PRofil
> Unix                      admin
> Unix                      dba
> Wintel                   toto
> CA                        tata
> Wintel                   admin
> CA                        migration

> merci de votre aide & bonne journ e
Avatar
DanielCo
Je n'ai pas écrit ce que cites, mais ça :
Me.ComboBox1.Clear
Daniel


BOnjour,

grand merci j'ai un probleme sur la ligne
Next c
Me.ComboBox17
.clear

J'ai utilisation incorrecte de la propriété
.

une idée ?
Avatar
sleg
désolé

ça fonctionne grand merci DanielCo

On 20 avr, 10:46, DanielCo wrote:
Je n'ai pas écrit ce que cites, mais ça :
Me.ComboBox1.Clear
Daniel







> BOnjour,

> grand merci j'ai un probleme sur la ligne
>   Next c
>         Me.ComboBox17
> .clear

> J'ai utilisation incorrecte de la propriété
> .

> une idée ?