Bonjour à tous,
je débute en vba (et programmation )
j'aimerais simplifier le code ci-dessous lorsque je teste si Feuil!L5 = bas, moyen, haut..
en effet, cela s'enchaîne mal.
il y a forcément une des trois possibilités donc comment faire pour les imbriquer?
du style:
if bas then...
else moyen then...
else if haut then...
merci
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Trouve As Range
Static mem As String
Static level As String
If mem <> Range("Feuil1!S7") Then
mem = Range("Feuil1!S7")
Set Trouve = Worksheets("Feuil3").Range("A:A").Find(Range("Feuil1!S7"), lookat:=xlWhole)
If Not Trouve Is Nothing Then
If Range("Feuil1!L5") = "bas" Then
Worksheets("Feuil3").Range("B" & Trouve.Row & ":E" & Trouve.Row).Copy Destination:=Worksheets("Feuil1").Range("O7:R7")
End If
If Range("Feuil1!L5") = "moyen" Then
Worksheets("Feuil3").Range("G" & Trouve.Row & ":J" & Trouve.Row).Copy Destination:=Worksheets("Feuil1").Range("O7:R7")
End If
If Range("Feuil1!L5") = "haut" Then
Worksheets("Feuil3").Range("L" & Trouve.Row & ":O" & Trouve.Row).Copy Destination:=Worksheets("Feuil1").Range("O7:R7")
End If
End If
End If
End Sub