Results 1 to 3 of 3

Thread: [Solved] Select multiple shapes in XLS

  1. #1

    Thread Starter
    Addicted Member Fonty's Avatar
    Join Date
    May 2006
    Location
    New York
    Posts
    173

    Resolved [Solved] Select multiple shapes in XLS

    I'm trying to select an array of specific shapes in a sheet.

    For example, assume there are some shapes in a sheet and you only want to select those matching the name in A1:A4.

    Just using this works:
    Code:
    ActiveSheet.Shapes.Range(Array("img1","img2","img3","img4")).Select
    I want to automate it and I wrote this but it doesn't work...

    Code:
    Dim my_range As Variant
    Dim test() As String
         
    ReDim test(4)
    For i = 0 To 4
    	test(i) = Cells(i + 1, 1).Value
    Next i
       
    Set my_range = ActiveSheet.Shapes.Range(test)
    my_range.Select
    It says "The specified parameter has an invalid value". What am i doing wrong?
    Last edited by Fonty; Feb 26th, 2012 at 09:23 PM.

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Select multiple shapes in XLS

    it can work if you dimension test as a variant array only
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

    Thread Starter
    Addicted Member Fonty's Avatar
    Join Date
    May 2006
    Location
    New York
    Posts
    173

    Re: Select multiple shapes in XLS

    You are awesome! Thanks a lot.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width