I am trying to align shapes to a specific range such as range(B2:Z2), currently the shapes align to where ever the command button is placed. I don't want the command button to be treated as a shape. In addition I want to have a set of rectangle shapes and a rounded rectangle shapes. I need the rectangles to align in range(B2:Z2) and the rounded rectangle to align in range(B6:Z6) with one or two command buttons. I have the code below for aligning shapes horizontally, but it works on all shapes rather than specific shapes.
Code:
Private Sub CommandButton21_Click()Dim Shp(1 To 100) As Shape
Dim x As Integer, y As Integer
Dim totWidth As Double
' counts number of shapes on page
x = ActiveSheet.Shapes.Count
For y = 1 To x
If Shp(1) Is Nothing Then
Set Shp(1) = ActiveSheet.Shapes(y)
totWidth = Shp(y).Width
Else
Set Shp(y) = ActiveSheet.Shapes(y)
Shp(y).Left = Shp(1).Left + totWidth
Shp(y).Top = Shp(1).Top
totWidth = totWidth + Shp(y).Width
End If
Next y
End Sub