Condition pour une valeur specifique dans if

jib92

XLDnaute Nouveau
Bonjour,

J'ai fait un programme avec moultes et moultes boucles et je m'y perds un peu.

Je voudrais savoir comment mettre une condition dans if pour une valeur spécifique:

En simplifiant:

For j = 1 To 5

If doesExistMotPrincipal(MotPrincipal, str) = True And CStr(ws2.Range("Z" & lg2).Value) = j And (For j=5 CStr(ws2.Range("X" & lg2).Value)=Var1 Or (CStr(ws2.Range("Y" & lg2).Value)=Var2) Then

Je veux que la macro teste la condition en gras pour j=5.

Est ce possible?

Merci
 

job75

XLDnaute Barbatruc
Re : Condition pour une valeur specifique dans if

Bonjour,

Voyez avec la fonction IIf :

Code:
If doesExistMotPrincipal(MotPrincipal, str) = True And CStr(ws2.Range("Z" & lg2).Value) = j And [COLOR="Red"]IIf[/COLOR](j=5, CStr(ws2.Range("X" & lg2).Value)=Var1 Or CStr(ws2.Range("Y" & lg2).Value)=Var2, [COLOR="Red"]True[/COLOR]) Then

A+
 

Discussions similaires

Réponses
7
Affichages
390

Statistiques des forums

Discussions
312 412
Messages
2 088 195
Membres
103 763
dernier inscrit
p.michaux