shp.IncrementLeft 146
плохая идея.Если ширина фигуры изменяется, это может привести к нежелательным результатам.
В дополнение к моим комментариям ниже вашего вопроса,
New position of shape = Left of old shape + Width of old shape + Margin space
Это то, что вы пытаетесь?
Option Explicit
Sub Sample()
Dim shp As Shape
Dim ws As Worksheet
Dim lstShp As Integer
Dim shpLft As Double, shpTop As Double, shpWidth As Double
Dim inBetweenMargin As Double
Dim i As Long
'~~> In betwen margin
inBetweenMargin = 25 '~~> 146????
'~~> Set this to the respective sheet
Set ws = Sheet2
With ws
'~~> Get the max shape number(name)
For Each shp In .Shapes
If shp.AutoShapeType = msoShapeRectangle Then
If Val(shp.Name) > 1 And Val(shp.Name) > lstShp Then _
lstShp = Val(shp.Name)
End If
Next
'~~> Loop through the shapes
For i = 1 To lstShp
'~~> This is required in case you delete shape 3
'~~> and have only shapes 1,2,4,5 etc...
On Error Resume Next
Set shp = .Shapes(Cstr(i))
On Error GoTo 0
'~~> position them
If Not shp Is Nothing Then
If shpLft = 0 And shpTop = 0 And shpWidth = 0 Then
shpLft = shp.Left
shpTop = shp.Top
shpWidth = shp.Width
Else
shp.Top = shpTop
shp.Left = shpLft + shpWidth + inBetweenMargin
shpLft = shp.Left
shpWidth = shp.Width
End If
End If
Next i
End With
End Sub
Снимок экрана
