I am having trouble selecting only the shapes that contain a specific string within the name. The red line in the code is my problem.
I am searching for all the shapes within the sheet, storing the names of the shapes I wan't in an array and placing the join output of the array into a string. I can't get past this point.
Sub autoAlignShapes2323()
Dim shp As Shape
Dim ws As Worksheet
Dim iButtonNames As Variant
Dim cnt As Byte
Dim btnStr As String
ReDim iButtonNames(1)
Set ws = Sheet1
cnt = 0
For Each shp In ws.Shapes
Debug.Print shp.Name
If InStr(1, shp.Name, "_Sheet", vbTextCompare) > 1 Then
ReDim Preserve iButtonNames(cnt)
iButtonNames(cnt) = Chr(34) & shp.Name & Chr(34)
cnt = cnt + 1
End If
Next
btnStr = Join(iButtonNames, ", ")
Debug.Print btnStr & vbNewLine & TypeName(btnStr)
ws.Shapes.Range(Array(btnStr)).Select
End Sub
Bookmarks