Using Arrays to select Shapes
I am having a problem building and then using an Array. Can anyone show me the errors of my way?
The following routine is called by another routine
Sub BuildArray(MyName)
On Error GoTo NotFound
If MyArray = "" Then
MyArray = MyName
Else
MyArray = MyArray & """, """ & MyName
End If
Exit Sub
NotFound:
Msg = "Selection is not on this Sheet."
Title = "Not Found"
Style = vbOKOnly
Response = MsgBox(Msg, Style, Title)
MyContinue = "No"
Exit Sub
End Sub
MyArray looks OK (i.e. I3890 150, I3890 160, I3890 170). Then the calling routine tries to use the array as follows:
¦
Worksheets(MySheet).Select
Worksheets(MySheet).Shapes.Range(Array(MyArray)).S elect
Selection.Cut
End Sub
But the result is Run-time error 1004. The item with the specified name wasnt found.
If I substitute the actual value of MyArray (i.e. I3890 150, I3890 160, I3890 170) in the calling program, it runs just fine. Whats with that?
Your assistance is greatly appreciated.
Don
|