Optimisation du code

N'y a t il pas plus court au niveau du code quand on a une plage nommée (cellules dans une même colonne) et une cellule unique un peu plus loin ( colonne différente) dans une feuille :

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Not Application.Intersect(Target, Range("Liste_Placement")) Is Nothing Then

If Target.Count > 1 Then Exit Sub

'Affiche sur clic le graphe sur 1 an

Call Affiche_Graphe_Cellule(Target.Value)

End If

If Not Application.Intersect(Target, Range("D26")) Is Nothing Then

If Target.Count > 1 Then Exit Sub

'Affiche sur clic le graphe Cac_40 sur 1 an

Call MAJ_Graphe_CAC_40(-52, "1 an")

End If

End Sub

Bonsoir

A tester

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

  If Target.Count > 1 Then Exit Sub

  If Not Application.Intersect(Target, Range("Liste_Placement")) Is Nothing Then
    'Affiche sur clic le graphe sur 1 an
    Call Affiche_Graphe_Cellule(Target.Value)
  ElseIf Not Application.Intersect(Target, Range("D26")) Is Nothing Then
    'Affiche sur clic le graphe Cac_40 sur 1 an
    Call MAJ_Graphe_CAC_40(-52, "1 an")
  End If

End Sub

Parfait. J'ai chargé, tout est bon. Merci banzaï.

Rechercher des sujets similaires à "optimisation code"