I am trying to group 13 textboxes and 1 chart together using Excel VBA, but I get the following runtime error:
"The index into the specified collection is out of bounds." Here is my code:
Sub Macro3()
Dim N As Integer
Dim I As Integer
Dim A As String
Dim C(1 To 14) As Variant
N = 0
For I = 1 To ActiveSheet.Shapes.Count
A = ActiveSheet.Shapes.Item(I).Name
If InStr(1, A, "TextBox") Or InStr(1, A, "Chart") Then
N = N + 1
C(N) = A
End If
Next I
'ReDim Preserve C(1 To N)
ActiveSheet.Shapes.Range(Array(C)).Select ' This is the line where I get the error.
Selection.ShapeRange.Group.Select
End Sub
Jim Benet