Sub Cacheligne5()
'***Fonctionne pour tous types de valeurs avec présence d'un seul graphique à divers emplacements sur la feuille
Dim DerL As Integer, DerC As Integer, i As Integer, j As Integer
Dim NB As Integer, NBlig As Byte, Htotcel As Double, Hmax As Double
With ActiveSheet
DerL = Selection.SpecialCells(xlCellTypeLastCell).Row
DerC = Selection.SpecialCells(xlCellTypeLastCell).Column
HGraph = .ChartObjects(1).Top
BGraph = .ChartObjects(1).Top + .ChartObjects(1).Height
'***Définition de la première ligne de graphe
Htotcel = 0
NBlig = 0
For i = 1 To DerL
If Htotcel < HGraph Then
Htotcel = Htotcel + Cells(i, 1).RowHeight
lig1 = lig1 + 1
Else
Exit For
End If
Next
'***Définition de la dernière ligne de graphe
Htotcel = 0
NBlig = 0
For i = 1 To DerL
If Htotcel < BGraph Then
Htotcel = Htotcel + Cells(i, 1).RowHeight
lig2 = lig2 + 1
Else
Exit For
End If
Next
'***Tri des lignes vides
For i = 1 To DerL
If i > lig1 And i < lig2 + 1 Then GoTo 1
NB = 0
For j = 1 To DerC
If Cells(i, j) <> 0 And Cells(i, j) <> "" Then Exit For
NB = NB + 1
Next
If NB = DerC Then .Rows(i).EntireRow.Hidden = True
1 Next
End With
End Sub