1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
|
Option Explicit
Public MatriceShapes() As Variant
Sub DetruireLesShapes()
Dim I As Long, J As Long, DerniereLigne As Long
Dim ShImages As Worksheet
Dim ASupprimer As Boolean
On Error GoTo Fin
Set ShImages = Sheets("Feuil1") ' A adapter
ChargementMatriceShapes ShImages
DerniereLigne = 0
For I = LBound(MatriceShapes, 2) To UBound(MatriceShapes, 2)
If MatriceShapes(1, I) > DerniereLigne Then DerniereLigne = MatriceShapes(1, I)
Next I
With ShImages
For I = LBound(MatriceShapes, 2) To UBound(MatriceShapes, 2)
.Shapes(MatriceShapes(0, I)).Delete
Next I
For J = DerniereLigne To 1 Step -1
ASupprimer = True
For I = LBound(MatriceShapes, 2) To UBound(MatriceShapes, 2)
If MatriceShapes(1, I) = J And ASupprimer = True Then
.Rows(MatriceShapes(1, I)).Delete
ASupprimer = False
End If
Next I
Next J
End With
Fin:
Set ShImages = Nothing
End Sub
Sub ChargementMatriceShapes(ByVal FeuilleImages As Worksheet)
Dim I As Long, J As Long, NbShapes As Long
Erase MatriceShapes
With FeuilleImages
NbShapes = 0
I = 0
J = 1
For NbShapes = .Shapes.Count To 1 Step -1
If .Range("AN" & .Shapes(NbShapes).TopLeftCell.Row) = "X" Then
ReDim Preserve MatriceShapes(1, I)
.Shapes(NbShapes).Name = "ASupprimer" & J
MatriceShapes(0, I) = .Shapes(NbShapes).Name
MatriceShapes(1, I) = .Shapes(NbShapes).TopLeftCell.Row
I = I + 1
J = J + 1
End If
Next NbShapes
End With
End Sub |
Partager