Sub SensAB()
ShapePlageSourceVersCelluleCible Range("b5:j23"), Range("o5")
End Sub
Sub SensBA()
ShapePlageSourceVersCelluleCible Range("o5:w24"), Range("b5")
End Sub
Sub ShapePlageSourceVersCelluleCible(PlageSource As Range, CelluleCible As Range)
Dim PlageCible As Range, xrgHaut As Range, xrgBas As Range, x As Shape, dx#, dy#, repSuppr
Set PlageCible = CelluleCible.Resize(PlageSource.Rows.Count, PlageSource.Columns.Count)
repSuppr = MsgBox("Voulez-vous supprimer toutes les formes ""ENTIèREMENT"" incluses" & _
" dans la zone cible ? (pas de retour possible !)", vbYesNo + vbQuestion + vbDefaultButton2)
If repSuppr = vbYes Then
repSuppr = MsgBox("CONFIRMEZ-VOUS la suppression de toutes les formes ""ENTIèREMENT"" incluses" & _
" dans la zone cible ? (pas de retour possible !)", vbYesNo + vbQuestion + vbDefaultButton2)
If repSuppr = vbYes Then
For Each x In Me.Shapes
If Not Intersect(x.TopLeftCell, PlageCible) Is Nothing Then
If Not Intersect(x.BottomRightCell, PlageCible) Is Nothing Then x.Delete
End If
Next x
End If
End If
dx = PlageCible.Left - PlageSource.Left: dy = PlageCible.Top - PlageSource.Top
For Each x In Me.Shapes
If Not Intersect(x.TopLeftCell, PlageSource) Is Nothing Then
If Not Intersect(x.BottomRightCell, PlageSource) Is Nothing Then
x.Top = x.Top + dy: x.Left = x.Left + dx
x.ZOrder msoBringToFront
End If: End If
Next x
End Sub