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
| Public Sub RedimShapes()
Dim shp As Shape
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
'shape du haut
Set shp = GetFirstShape(ws)
If Not shp Is Nothing Then
shp.Width = 75
shp.Height = 75
shp.Top = ws.Range("H2").Top
shp.Left = ws.Range("H2").Left
End If
'shape du bas
Set shp = GetFirstShape(ws, True)
If Not shp Is Nothing Then
shp.Width = 75
shp.Height = 75
shp.Top = ws.Range("I20").Top
shp.Left = ws.Range("I20").Left
End If
Next ws
End Sub
Private Function GetFirstShape(ws As Worksheet, Optional fromBottom As Boolean = False) As Shape
Dim topRow As Long
Dim shp As Shape
topRow = IIf(fromBottom, 0, ws.Rows.Count)
For Each shp In ws.Shapes
If ((Not fromBottom) And (shp.TopLeftCell.Row < topRow)) Or (fromBottom And (shp.TopLeftCell.Row > topRow)) Then
topRow = shp.TopLeftCell.Row
Set GetFirstShape = shp
End If
Next shp
End Function |
Partager