Re: programmatically selecting multiple shapes
From: Tom Ogilvy (twogilvy_at_msn.com)
Date: 02/18/05
- Next message: Jim Thomlinson: "RE: counting..."
- Previous message: Jim Thomlinson: "RE: Macro no workie workie - Help Please"
- In reply to: ACW: "Re: programmatically selecting multiple shapes"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 18 Feb 2005 13:00:40 -0500
this worked for me:
Sub AAA()
Dim j As Long, i As Long
Dim varr(0 To 2)
j = 0
For i = 1 To 6 Step 2
varr(j) = i
j = j + 1
Next
ActiveSheet.Shapes.Range(varr). _
Select
End Sub
Not very dynamic as written, but could be modified.
--
Regards,
Tom Ogilvy
"ACW" <ACW.1knsfq@excelforum-nospam.com> wrote in message
news:ACW.1knsfq@excelforum-nospam.com...
>
> Thanks Leith.
>
> This is also where I got stuck. Like you mention below, what
> code/method will select a set of shapes during run time?
>
> I can actually get buy with a hardcoded list of shapes, but I rather
> not for robustness.
>
> Perhaps there's a way to build the list that can be given to the array
> function. I tried that using an array of strings "Array(MyArrayList)",
> but that results in a two dimensional array and the error message "type
> mismatch". So, then I tried simply using a array of strings and then
> "MyArrayList". This resulted in the same error message. The sample code
> below. I also tried making MyArray a Variant with the same result.
>
>
> Dim MyArray(3) As String
>
>
> MyArray(0) = 1
> MyArray(1) = 3
> MyArray(2) = 4
>
> ActiveSheet.Shapes(Array(MyArray)).Select
> ActiveSheet.Shapes(MyArray).Select
>
> Thanks again. I really appreciate you helping me look into this.
>
>
>
> Leith Ross Wrote:
> > Hi Again ACW,
> >
> > This is an addendum to the last post. I figured out what I was doing
> > wrong.
> >
> > You can select the Shapes by Index Number, and without having to select
> > them all first!
> > _________________________________________________________________
> >
> > EXAMPLE - SAY THERE ARE 10 SHAPES ON WORKSHEET \"SHEET1\" AND YOU WANT
> > TO SELECT 3 OF YOUR CHOOSING. THIS IS HOW:
> >
> > Sheets("Sheet1").Shapes.Range(Array(1, 3, 7)).Select
> > _________________________________________________________________
> >
> > The drawback is the Array is integrated into the code segment. In other
> > words, the number of elements is set at design time. Haven't figured out
> > a work around for this yet, if there is one. Now at least, you don't
> > have to use the names to select the shape.
> >
> > Sorry for the inconvenience,
> > Leith Ross
>
>
> --
> ACW
> ------------------------------------------------------------------------
> ACW's Profile:
http://www.excelforum.com/member.php?action=getinfo&userid=20033
> View this thread: http://www.excelforum.com/showthread.php?threadid=346145
>
- Next message: Jim Thomlinson: "RE: counting..."
- Previous message: Jim Thomlinson: "RE: Macro no workie workie - Help Please"
- In reply to: ACW: "Re: programmatically selecting multiple shapes"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|