View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Don Rouse Don Rouse is offline
external usenet poster
 
Posts: 29
Default 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