Fonction VBA

Bonjour,

Est-il possible de simplifier cette ligne de commande If /Or :

If Cells(l, 7) = Cells(l, 1) Or Cells(l, 7) = Cells(l, 2) Or Cells(l, 7) = Cells(l, 3) Or Cells(l, 7) = Cells(l, 4) Or Cells(l, 7) = Cells(l, 5) Then Cells(l, "8") = 1 Else Cells(l, "8") = 0

Merci

ps j'ai écrit "8" à cause du smiley.

Bonjour,

Si j'ai bien traduit :

[A8] = IIf(Application.CountIf([A1:A7], [G1]), 1, 0)

eric

Bonjour Eric,

Pourquoi A8? C'est une boucle avec la lettre l de forme Cells(L , 7) (j'ai mis L en majuscule pour bien voir, l étant la ligne et 7 la colonne)

merci.

J'avais mal lu, sorry...

Le principe reste le même. A tester :

Cells(l, "J") = IIf(Application.CountIf(Cells(l, 1).Resize(, 5), Cells(l, "G")), 1, 0)

eric

Merci Eric ça fonctionne bien (c'est pas J mais H)

Je pense à la condition If , elle ne sert à rien car il suffit de compter? (ce serait plus simple)

Pour chaque ligne L, UN nombre (en G) à comparer avec les nombres en A B C D E (de la ligne L), le comptage ne peut donner que 1 ou 0 en H (vu qu'il n'y a qu'un nombre en G) !

On pourrait simplifier la ligne sans le If, non? ton avis merci.

Re,

C'est parfait tout fonctionne avec Cells(l, "H") = Application.CountIf(Cells(l, 1).Resize(, 5), Cells(l, "G"))

Merci

a+

Rechercher des sujets similaires à "fonction vba"