For each : si c = "A" alors c suivant

carlos

XLDnaute Impliqué
Supporter XLD
Bonjour

voici ma macro :

'Donner un numero aleatoire à chq eleve de 1 à n

For Each c In Plage
If c = 'A' Then c = 'A'
Do
c = Int(27 * Rnd()) + 1
Loop Until Application.CountIf(Range('g4:g' & c.Row), c) = 1
Next c


J'aimerais que si c = 'A' alors c = 'A' ET on passe à la cellule suivante c.Offset(1, 0)

merci
 

Creepy

XLDnaute Accro
Hello,

je suis par sure de bien comprendre ta demande mais je pense que tu veux ca :

For Each c In Plage
If c = 'A' Then NEXT
Do
c = Int(27 * Rnd()) + 1
Loop Until Application.CountIf(Range('g4:g' & c.Row), c) = 1
Next c

++

Creepy
 

Hervé

XLDnaute Barbatruc
Bonjour à vous deux

moi aussi, pas sur d'avoir compris :

Mais il manque un : end if

For Each c In Plage
If c <> 'A' Then
Do
c = Int(27 * Rnd()) + 1
Loop Until Application.CountIf(Range('g4:g' & c.Row), c) = 1
end if
Next c

Salut
 

carlos

XLDnaute Impliqué
Supporter XLD
Bonjour Hervé et Creepy

Encore une fois nos chemins se croisent

Merci pour vos propositions , ca marche impec mais g du mal à comprendre p, au vu de ton code 'If c <> 'A' Then
Do etc...'pourquoi à la place du 'A' il ne met pas une valeur aleatoire et pourquoi il embraye sur la c suivante ???

Merci
 

Discussions similaires

Statistiques des forums

Discussions
314 011
Messages
2 104 528
Membres
109 063
dernier inscrit
rahimmcsaw