Mettre boucle for dans condition if VBA

Fermé
Jack - 9 juil. 2012 à 11:21
vordano Messages postés 1682 Date d'inscription mardi 12 juillet 2011 Statut Membre Dernière intervention 20 juillet 2012 - 10 juil. 2012 à 16:42
Bonjour,

Je voudrais savoir s'il était possible de mettre un boucle for dans une condition if, par exemple:

if UBound(tab_bd)>0 and
for c=0 to UBound(tab_bd)
cells(tab_bd(c),6)=cells(tab_bd(0),6)
cells(tab_bd(c),7)=cells(tab_bd(0),7)
cells(tab_bd(c),8)=cells(tab_bd(0),8)
then
msgbox("ok")
end if

Pour l'instant ça ne marche pas...
Merci d'avance à ceux qui pourront m'éclairer sur ce point.

16 réponses

Bonjour,
On ne vout pas trop ce que tu cherches à faire ..
Essaie ça :

dim bTrouvé as boolean ;
bTrouvé = false ;

if UBound(tab_bd)>0 then
for c=0 to UBound(tab_bd)
if cells(tab_bd(c),6)=cells(tab_bd(0),6) and
cells(tab_bd(c),7)=cells(tab_bd(0),7) and
cells(tab_bd(c),8)=cells(tab_bd(0),8) then
bTrouvé = true ;
exit for ;
next ;
end if ;
if bTrouvé then msgbox("OK") ;

cdlt
0