Plantage avec INDIRECT dans une macro

Bonjour,

Je cherche à faire une macro qui instancierait des listes dépendantes.

En D4 j'instancie un menu deroulant qui propose les mots de la liste mère

En D5 je voudrais le menu déroulant de la liste fille

si je le fait à la main ca fonctionne...

Dans la macro, La première liste est faite come ca:

.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= xlBetween, Formula1:="=ListeMere"

La seconde:

.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= xlBetween, Formula1:="=INDIRECT(D4)"

Ca fait planter ma macro !!

Avez vous une idée de comment je pourrait instancier ma seconde liste ??

Merci

bonjour,

ceci fonctionne chez moi

    With Range("F1").Validation
        .Delete
        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:="=ListeMere"
    End With
    With Range("G1").Validation
        .Delete
        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:="=indirect(f1)"
    End With

Chez moi non!

Ca plante à la ligne :

.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:="=indirect(f1)"

il y a une autre facon de le faire ??

Bonjour Peanut-Mary

Encore une différence entre PC et Mac

Il va être compliqué de vous aider, je pense.

bonjour,

à vérifier, pour que l'instruction passe il faut que la cellule F1 contienne une référence valide. En tout cas, sur PC windows.

    With Range("F1").Validation
        .Delete
        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:="=ListeMere"
    End With
    Range("f1") = Range("listemere").Cells(1, 1).Value 'initialise F1 avec une adresse valide
    With Range("G1").Validation
        .Delete
        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:="=indirect(f1)"
    End With
    Range("f1") = ""

Pas mieux ! :-(

Merci en tout les cas !!

Rechercher des sujets similaires à "plantage indirect macro"