Ceci est une page optimisée pour les mobiles. Cliquez sur ce texte pour afficher la vraie page.

Menu déroulant variable par macro dans un option button

lepigoennier

XLDnaute Junior
Bonjour à tous,

J'ai un document de de soumission où je dois choisir (par optionbutton) un des 3 entrepôts. Lorsque l'entrepôt est choisi, mes combobox se remplissent avec les fournisseurs de cet entrepôt. Mon problème est que la liste de fournisseur peut s'allonger mais que mes combobox ne se mettent pas à jour. Comment puis-je faire la mise à jour automatique sans aller dans le code? Voici mon code pour 1 des 3 optionbutton.

Code:
Private Sub OptionButton3_Click() 
        With ComboBox1
        .Text = ""
        
        .ListFillRange = "'Menus déroulants'!G3:G333"
        .LinkedCell = "$C$24"
    End With
    
    With ComboBox4
        .Text = ""
        .ListFillRange = "'Menus déroulants'!G3:G333"
        .LinkedCell = "$C$25"
    End With
    
    With ComboBox2
        .Text = ""
        .ListFillRange = "'Menus déroulants'!G3:G333"
        .LinkedCell = "$C$26"
    End With
    
    With ComboBox5
        .Text = ""
        .ListFillRange = "'Menus déroulants'!G3:G333"
        .LinkedCell = "$C$27"
    End With
    
    With ComboBox6
        .Text = ""
        .ListFillRange = "'Menus déroulants'!G3:G333"
        .LinkedCell = "$C$28"
    End With
    
    With ComboBox3
        .ListFillRange = "'Menus déroulants'!B3:B17"
        .LinkedCell = "$B$6"
    End With
    
    Call Macro3
End Sub

De plus lorsque je choisi un fournisseur, son courriel son adresse et son # apparait dans 3 cellules différentes dont voici le code

Code:
Private Sub ComboBox1_Change()
    
    If OptionButton3.Value = True Then
        Range("F24").Select
        ActiveCell.FormulaR1C1 = _
        "=IF(OR(ISNA(RC[-3]),ISBLANK(RC[-3]))=TRUE,"""",VLOOKUP(RC[-3],'Menus déroulants'!C[1]:C[4],2,FALSE))"
        Range("H24").Select
        ActiveCell.FormulaR1C1 = _
        "=IF(OR(ISNA(RC[-5]),ISBLANK(RC[-5]))=TRUE,"""",VLOOKUP(RC[-5],'Menus déroulants'!C[-1]:C[2],3,FALSE))"
        Range("J24").Select
        ActiveCell.FormulaR1C1 = _
        "=IF(OR(ISNA(RC[-7]),ISBLANK(RC[-7]))=TRUE,"""",VLOOKUP(RC[-7],'Menus déroulants'!C[-3]:C,4,FALSE))"
        Range("A27").Select
                
        Else
    If OptionButton2.Value = True Then
        Range("F24").Select
        ActiveCell.FormulaR1C1 = _
        "=IF(OR(ISNA(RC[-3]),ISBLANK(RC[-3]))=TRUE,"""",VLOOKUP(RC[-3],'Menus déroulants'!C[11]:C[14],2,FALSE))"
        Range("H24").Select
        ActiveCell.FormulaR1C1 = _
        "=IF(OR(ISNA(RC[-5]),ISBLANK(RC[-5]))=TRUE,"""",VLOOKUP(RC[-5],'Menus déroulants'!C[9]:C[12],3,FALSE))"
        Range("J24").Select
        ActiveCell.FormulaR1C1 = _
        "=IF(OR(ISNA(RC[-7]),ISBLANK(RC[-7]))=TRUE,"""",VLOOKUP(RC[-7],'Menus déroulants'!C[7]:C[10],4,FALSE))"
        Range("A27").Select
        
    Else
    If OptionButton1.Value = True Then
        Range("F24").Select
        ActiveCell.FormulaR1C1 = _
        "=IF(OR(ISNA(RC[-3]),ISBLANK(RC[-3]))=TRUE,"""",VLOOKUP(RC[-3],'Menus déroulants'!C[6]:C[9],2,FALSE))"
        Range("H24").Select
        ActiveCell.FormulaR1C1 = _
        "=IF(OR(ISNA(RC[-5]),ISBLANK(RC[-5]))=TRUE,"""",VLOOKUP(RC[-5],'Menus déroulants'!C[4]:C[7],3,FALSE))"
        Range("J24").Select
        ActiveCell.FormulaR1C1 = _
        "=IF(OR(ISNA(RC[-7]),ISBLANK(RC[-7]))=TRUE,"""",VLOOKUP(RC[-7],'Menus déroulants'!C[2]:C[5],4,FALSE))"
        Range("A27").Select
        
        
        
        
    Else
    End If
    End If
    End If
    
End Sub

Merci de m'aider à résoudre ce casse-tête
 

camarchepas

XLDnaute Barbatruc
Re : Menu déroulant variable par macro dans un option button

Bonjour,

un petit fichier support avec le userform et la structure de données serait bien utile pour te fournir quelque chose qui correspond à ton besoin
 
Les cookies sont requis pour utiliser ce site. Vous devez les accepter pour continuer à utiliser le site. En savoir plus…