Cellule occupée par graphique

Résolu
julien -  
Patrice33740 Messages postés 8930 Statut Membre -
Bonjour,


Je me demande si une fonction permet de vérifier si le Range("X") contient un graphique .. ?

Je fait avec If Range("X")<>0

Mais il me dise que la cellule est vide alors qu'il y a un graphique dedans ..

Merci

1 réponse

Patrice33740 Messages postés 8930 Statut Membre 1 780
 
Bonjour,

Avec une fonction personnalisée :
Sub Test()
  If IlyaUnGraphiqueSurLaPlage(ActiveCell) Then
    MsgBox "Il y a un graphique sur " & ActiveCell.Address(0, 0)
  End If
End Sub

Private Function IlyaUnGraphiqueSurLaPlage(r As Range) As Boolean
Dim s As Shape
With r.Parent
 For Each s In .Shapes
  If Not Intersect(r, .Range(s.TopLeftCell, s.BottomRightCell)) _
         Is Nothing Then
   IlyaUnGraphiqueSurLaPlage = True
   Exit Function
  End If
 Next s
End With
End Function
 

Cordialement
Patrice
0