Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

If then Else et "and" "or" etc...

1 réponse
Avatar
fifigim
Bonjour,

Je souhaiterai exécuter une macro, qui est l'affichage d'une image, jusque
la, tout va bien...
Cependant, je voudrai plusieurs conditions, c'est à dire, "si a=1 ou si b=2
et c=3", alors, affichage. Mais je ne m'en sors pas... Merci d'avance pour
votre aide.

ps : la macro en question :

If Range("l13").Value = 4 or if Range("l13").Value = 2 and
Range("l60").Value < 150 Then
'C'est ici que je voudrai plus de conditions, "or" et "and" ne fonctionnent
pas'

If Range("l42").Value >= 4 Then
If Range("o5").Value = 0 Then
If Range("l46").Value >= 4 Then

Application.ScreenUpdating = False
Set Sh = Worksheets("Boites aux Lettres").Shapes("Image 49").Duplicate
Sh.CopyPicture

With Worksheets("Boite aux Lettres")
.Activate
.Paste
With .Range("d22:g42")
Selection.Top = .Top
Selection.Left = .Left
Selection.Height = .Height
Selection.Width = .Width
.Select
End With
End With

End If
End If
End If
End If
End If

End Sub

1 réponse

Avatar
ChrisV
Bonjour

Sub zaza()
a = 1
b = 2
c = 3

If (a = 1 Or b = 2) And c = 3 Then
MsgBox "condition vérifiée"
Else: MsgBox "condition non-vérifiée"
End If

End Sub


ChrisV


"fifigim" a écrit dans le message de
news:
Bonjour,

Je souhaiterai exécuter une macro, qui est l'affichage d'une image, jusque
la, tout va bien...
Cependant, je voudrai plusieurs conditions, c'est à dire, "si a=1 ou si
b=2
et c=3", alors, affichage. Mais je ne m'en sors pas... Merci d'avance pour
votre aide.

ps : la macro en question :

If Range("l13").Value = 4 or if Range("l13").Value = 2 and
Range("l60").Value < 150 Then
'C'est ici que je voudrai plus de conditions, "or" et "and" ne
fonctionnent
pas'

If Range("l42").Value >= 4 Then
If Range("o5").Value = 0 Then
If Range("l46").Value >= 4 Then

Application.ScreenUpdating = False
Set Sh = Worksheets("Boites aux Lettres").Shapes("Image 49").Duplicate
Sh.CopyPicture

With Worksheets("Boite aux Lettres")
.Activate
.Paste
With .Range("d22:g42")
Selection.Top = .Top
Selection.Left = .Left
Selection.Height = .Height
Selection.Width = .Width
.Select
End With
End With

End If
End If
End If
End If
End If

End Sub