Bonjour à tous,
Je souhaiterai répéter ma macro ci-dessous sur plusieurs lignes (jusqu'à la ligne 48).
Dans l'exemple ci-dessous je l'ai crée pour 3 lignes, j'aimerai éviter de le faire 48 fois
Avez-vous une idée comment faire svp (faut-il faire une boucle ou y a t-il un autre moyen) ? :
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim isect, Z$, plage
If Target.Count = 1 Then
Z = Target.Value
plage = "h18"
Set isect = Application.Intersect(Target, Range(plage))
If Not isect Is Nothing Then
Target = IIf(Z = "", "ü", "")
Range("j18") = IIf(Target = "", "ü", "")
End If
plage = "j18"
Set isect = Application.Intersect(Target, Range(plage))
If Not isect Is Nothing Then
Target = IIf(Z = "", "ü", "")
Range("h18") = IIf(Target = "", "ü", "")
End If
plage = "Q24"
Set isect = Application.Intersect(Target, Range(plage))
If Not isect Is Nothing Then
Target = IIf(Z = "", "ü", "")
Range("r24") = IIf(Target = "", "ü", "")
End If
plage = "r24"
Set isect = Application.Intersect(Target, Range(plage))
If Not isect Is Nothing Then
Target = IIf(Z = "", "ü", "")
Range("s24") = IIf(Target = "", "ü", "")
End If
plage = "s24"
Set isect = Application.Intersect(Target, Range(plage))
If Not isect Is Nothing Then
Target = IIf(Z = "", "ü", "")
Range("q24") = IIf(Target = "", "ü", "")
End If
plage = "q24"
Set isect = Application.Intersect(Target, Range(plage))
If Not isect Is Nothing Then
Target = IIf(Z = "", "ü", "")
Range("s24") = IIf(Target = "", "ü", "")
End If
plage = "r24"
Set isect = Application.Intersect(Target, Range(plage))
If Not isect Is Nothing Then
Target = IIf(Z = "", "ü", "")
Range("q24") = IIf(Target = "", "ü", "")
End If
plage = "s24"
Set isect = Application.Intersect(Target, Range(plage))
If Not isect Is Nothing Then
Target = IIf(Z = "", "ü", "")
Range("r24") = IIf(Target = "", "ü", "")
End If
'ligne suivante
plage = "Q25"
Set isect = Application.Intersect(Target, Range(plage))
If Not isect Is Nothing Then
Target = IIf(Z = "", "ü", "")
Range("r25") = IIf(Target = "", "ü", "")
End If
plage = "r25"
Set isect = Application.Intersect(Target, Range(plage))
If Not isect Is Nothing Then
Target = IIf(Z = "", "ü", "")
Range("s25") = IIf(Target = "", "ü", "")
End If
plage = "s25"
Set isect = Application.Intersect(Target, Range(plage))
If Not isect Is Nothing Then
Target = IIf(Z = "", "ü", "")
Range("q25") = IIf(Target = "", "ü", "")
End If
plage = "q25"
Set isect = Application.Intersect(Target, Range(plage))
If Not isect Is Nothing Then
Target = IIf(Z = "", "ü", "")
Range("s25") = IIf(Target = "", "ü", "")
End If
plage = "r25"
Set isect = Application.Intersect(Target, Range(plage))
If Not isect Is Nothing Then
Target = IIf(Z = "", "ü", "")
Range("q25") = IIf(Target = "", "ü", "")
End If
plage = "s25"
Set isect = Application.Intersect(Target, Range(plage))
If Not isect Is Nothing Then
Target = IIf(Z = "", "ü", "")
Range("r25") = IIf(Target = "", "ü", "")
End If
'ligne suivante
plage = "Q26"
Set isect = Application.Intersect(Target, Range(plage))
If Not isect Is Nothing Then
Target = IIf(Z = "", "ü", "")
Range("r26") = IIf(Target = "", "ü", "")
End If
plage = "r26"
Set isect = Application.Intersect(Target, Range(plage))
If Not isect Is Nothing Then
Target = IIf(Z = "", "ü", "")
Range("s26") = IIf(Target = "", "ü", "")
End If
plage = "s26"
Set isect = Application.Intersect(Target, Range(plage))
If Not isect Is Nothing Then
Target = IIf(Z = "", "ü", "")
Range("q26") = IIf(Target = "", "ü", "")
End If
plage = "q26"
Set isect = Application.Intersect(Target, Range(plage))
If Not isect Is Nothing Then
Target = IIf(Z = "", "ü", "")
Range("s26") = IIf(Target = "", "ü", "")
End If
plage = "r26"
Set isect = Application.Intersect(Target, Range(plage))
If Not isect Is Nothing Then
Target = IIf(Z = "", "ü", "")
Range("q26") = IIf(Target = "", "ü", "")
End If
plage = "s26"
Set isect = Application.Intersect(Target, Range(plage))
If Not isect Is Nothing Then
Target = IIf(Z = "", "ü", "")
Range("r26") = IIf(Target = "", "ü", "")
End If
Je souhaiterai répéter ma macro ci-dessous sur plusieurs lignes (jusqu'à la ligne 48).
Dans l'exemple ci-dessous je l'ai crée pour 3 lignes, j'aimerai éviter de le faire 48 fois
Avez-vous une idée comment faire svp (faut-il faire une boucle ou y a t-il un autre moyen) ? :
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim isect, Z$, plage
If Target.Count = 1 Then
Z = Target.Value
plage = "h18"
Set isect = Application.Intersect(Target, Range(plage))
If Not isect Is Nothing Then
Target = IIf(Z = "", "ü", "")
Range("j18") = IIf(Target = "", "ü", "")
End If
plage = "j18"
Set isect = Application.Intersect(Target, Range(plage))
If Not isect Is Nothing Then
Target = IIf(Z = "", "ü", "")
Range("h18") = IIf(Target = "", "ü", "")
End If
plage = "Q24"
Set isect = Application.Intersect(Target, Range(plage))
If Not isect Is Nothing Then
Target = IIf(Z = "", "ü", "")
Range("r24") = IIf(Target = "", "ü", "")
End If
plage = "r24"
Set isect = Application.Intersect(Target, Range(plage))
If Not isect Is Nothing Then
Target = IIf(Z = "", "ü", "")
Range("s24") = IIf(Target = "", "ü", "")
End If
plage = "s24"
Set isect = Application.Intersect(Target, Range(plage))
If Not isect Is Nothing Then
Target = IIf(Z = "", "ü", "")
Range("q24") = IIf(Target = "", "ü", "")
End If
plage = "q24"
Set isect = Application.Intersect(Target, Range(plage))
If Not isect Is Nothing Then
Target = IIf(Z = "", "ü", "")
Range("s24") = IIf(Target = "", "ü", "")
End If
plage = "r24"
Set isect = Application.Intersect(Target, Range(plage))
If Not isect Is Nothing Then
Target = IIf(Z = "", "ü", "")
Range("q24") = IIf(Target = "", "ü", "")
End If
plage = "s24"
Set isect = Application.Intersect(Target, Range(plage))
If Not isect Is Nothing Then
Target = IIf(Z = "", "ü", "")
Range("r24") = IIf(Target = "", "ü", "")
End If
'ligne suivante
plage = "Q25"
Set isect = Application.Intersect(Target, Range(plage))
If Not isect Is Nothing Then
Target = IIf(Z = "", "ü", "")
Range("r25") = IIf(Target = "", "ü", "")
End If
plage = "r25"
Set isect = Application.Intersect(Target, Range(plage))
If Not isect Is Nothing Then
Target = IIf(Z = "", "ü", "")
Range("s25") = IIf(Target = "", "ü", "")
End If
plage = "s25"
Set isect = Application.Intersect(Target, Range(plage))
If Not isect Is Nothing Then
Target = IIf(Z = "", "ü", "")
Range("q25") = IIf(Target = "", "ü", "")
End If
plage = "q25"
Set isect = Application.Intersect(Target, Range(plage))
If Not isect Is Nothing Then
Target = IIf(Z = "", "ü", "")
Range("s25") = IIf(Target = "", "ü", "")
End If
plage = "r25"
Set isect = Application.Intersect(Target, Range(plage))
If Not isect Is Nothing Then
Target = IIf(Z = "", "ü", "")
Range("q25") = IIf(Target = "", "ü", "")
End If
plage = "s25"
Set isect = Application.Intersect(Target, Range(plage))
If Not isect Is Nothing Then
Target = IIf(Z = "", "ü", "")
Range("r25") = IIf(Target = "", "ü", "")
End If
'ligne suivante
plage = "Q26"
Set isect = Application.Intersect(Target, Range(plage))
If Not isect Is Nothing Then
Target = IIf(Z = "", "ü", "")
Range("r26") = IIf(Target = "", "ü", "")
End If
plage = "r26"
Set isect = Application.Intersect(Target, Range(plage))
If Not isect Is Nothing Then
Target = IIf(Z = "", "ü", "")
Range("s26") = IIf(Target = "", "ü", "")
End If
plage = "s26"
Set isect = Application.Intersect(Target, Range(plage))
If Not isect Is Nothing Then
Target = IIf(Z = "", "ü", "")
Range("q26") = IIf(Target = "", "ü", "")
End If
plage = "q26"
Set isect = Application.Intersect(Target, Range(plage))
If Not isect Is Nothing Then
Target = IIf(Z = "", "ü", "")
Range("s26") = IIf(Target = "", "ü", "")
End If
plage = "r26"
Set isect = Application.Intersect(Target, Range(plage))
If Not isect Is Nothing Then
Target = IIf(Z = "", "ü", "")
Range("q26") = IIf(Target = "", "ü", "")
End If
plage = "s26"
Set isect = Application.Intersect(Target, Range(plage))
If Not isect Is Nothing Then
Target = IIf(Z = "", "ü", "")
Range("r26") = IIf(Target = "", "ü", "")
End If