Bonjour
je tourne en rond sur un problème tout simple
j'avais définit dans mon code VBA la validation de certaines cellules avec un formule
comme ceci
ce qui marche très bien.Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 Worksheets(feuille).Cells(i, colnom).Select With Selection.Validation .Delete .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _ xlBetween, Formula1:= _ "SI($B4=GRP_HUILE;LISTE_GRP_HUILE;SI($B4=GRP_HY;LISTE_GRP_HY;SI($B4=GRP_HE;LISTE_GRP_HE;LISTE_GRP_AUTRE)))" .IgnoreBlank = True .InCellDropdown = True .InputTitle = "" .ErrorTitle = "" .InputMessage = "" .ErrorMessage = "" .ShowInput = True .ShowError = True End With
Mais je dois revoir ma formule et elle devient dynamique (le référentiel des Noms à utiliser dans la formule étant lui même généré dynamiquement)
ce qui veut dire que je voudrais tout simplement remplacé dans mon code la formule par une variable
comme ceci
oùCode:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 Worksheets(feuille).Cells(i, colnom).Select With Selection.Validation .Delete .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _ xlBetween, Formula1:=Libformule .IgnoreBlank = True .InCellDropdown = True .InputTitle = "" .ErrorTitle = "" .InputMessage = "" .ErrorMessage = "" .ShowInput = True .ShowError = True End With
mon champ (string) Libformule est définit "à part" , pour l'instant j'ai juste remis exactement la même formule comme suit
mais ça ne marche pas !!Code:libformule = "SI($B4=GRP_HUILE;LISTE_GRP_HUILE;SI($B4=GRP_HY;LISTE_GRP_HY;SI($B4=GRP_HE;LISTE_GRP_HE;LISTE_GRP_AUTRE)))"
Merci d'avance pour votre aide