probleme if else

judoka0209

XLDnaute Occasionnel
bonjour petit probleme de if else
merci

Private Sub Worksheet_Change(ByVal Target As Range)

If Application.Intersect(Target, Range("C6:NC11,C15:NC20,c24:NC29,C33:NC38,C42:NC47,C51:NC56")) Is Nothing Then Exit Sub

' initialisation lignes début et fin en fonction de la plage
If Target.Row < 15 Then
LD = 6: LF = 11
Else
LD = 15: LF = 20
Else
LD = 24: LF = 29
Else
LD = 24: LF = 29
Else
LD = 33: LF = 38
Else
LD = 42: LF = 57
Else
LD = 51: LF = 56
End If
 

Dranreb

XLDnaute Barbatruc
Bonjour.
Je dirais un truc comme ça à priori :
VB:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Trop As Long, LD As Long, LF As Long
If Intersect([C:NC], Target) Is Nothing Then Exit Sub
' initialisation lignes début et fin en fonction de la plage
Trop = (Target.Row - 6) Mod 9
If Trop < 0 Or Trop > 5 Then Exit Sub
LD = Target.Row - Trop: LF = LD + 5
 

Discussions similaires

Membres actuellement en ligne

Statistiques des forums

Discussions
313 344
Messages
2 097 337
Membres
106 916
dernier inscrit
Soltani mohamed