Mettre boucle for dans condition if VBA

Jack -  
vordano Messages postés 1981 Statut Membre -
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

  1. Titi-21
     
    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