Comparer les mots d'une cellule avec condition

kesispass Messages postés 3 Date d'inscription   Statut Membre Dernière intervention   -  
Pierre1310 Messages postés 8564 Date d'inscription   Statut Membre Dernière intervention   -
Bonjour,

Je voudrais comparer les mots de 2 cellules. le mot à écrire dans une case sera comparé au mots d'une case précédement tiré au hasard.

Je commence juste à toucher au macro et je ne comprend pas pourquoi j'ai un message qui dit "end if sans bloc if".

Voici ma macro.


Sub Océanie()


i = ActiveSheet.Range("I65536").End(xlUp).Row

suite:


o = Int(((i + 1) * Rnd()))


If o = 0 Then

GoTo suite
Else

ActiveSheet.Cells(18, 17) = ActiveSheet.Cells(o, 9).Value
ActiveSheet.Cells(5, 15) = o
End If


Range("Q6").Interior.ColorIndex = 1
Range("Q10").Interior.ColorIndex = 1
Range("Q14").Interior.ColorIndex = 1
Range("Q18").Interior.ColorIndex = 2
Range("Q22").Interior.ColorIndex = 1
Range("Q2").Interior.ColorIndex = 1
Range("R6").Interior.ColorIndex = 1
Range("R10").Interior.ColorIndex = 1
Range("R14").Interior.ColorIndex = 1
Range("R18").Interior.ColorIndex = 2
Range("R22").Interior.ColorIndex = 1
Range("R2").Interior.ColorIndex = 1

While o = 1

If Cells(18, 17) Like "*Camberra*" Then GoTo suite
End If

Wend


End Sub

J'ai rajouté ce qu'il y a en gras et depuis je ne peut plus compiler.

Quelqu'un serait il ou je me suis trompé?

1 réponse

Pierre1310 Messages postés 8564 Date d'inscription   Statut Membre Dernière intervention   651
 
Bonsoir,

if(cells(a,b) like cells(c,d)then
blablabla
end if

De plus tu as un boucle infinie vu que si ton o passe à 1 il ne repasse jamais à 0 donc ne ressors jamais de ta boucle.
Si tu veux faire une boucle, utilise un for ça marche très bien

a +
0