Microsoft® Excel® based database addin

 

+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Harry Guest

    Default How do i read Selection.Shapes.Range(Array(i)?

    I'm writing a macro that will rearrange a group of selected drawn rectangles.
    I need to select the rectangles and execute the macro which will modify an
    array that contains the rectangle coordinates. The rectangles will be deleted
    and redrawn in their new positions. Stacking random boxes may be a better way
    to put it.

    capturing the selection gives me:

    ActiveSheet.Shapes.Range(Array(" 62", " 63", " 64", " 65" _
    , " 66", " 67")).Select

    The macro i'm trying to execute is:

    Dim mr(100)

    With Selection
    num = .Count ' return number of rectangles (this works)
    for i = 1 to num
    sr = .Item(i) ' this should return " 62" but it doesn't
    need help here)
    mr(i) = Val(sr)
    Next i
    End With

    Any help or ideas would be greatly appreciated.

    --
    Best Regards,

    Harry

  2. #2
    Norman Jones Guest

    Default Re: How do i read Selection.Shapes.Range(Array(i)?

    Hi Harry,

    The following worked for me:

    '==================>>
    Public Sub Tester2()
    Dim mr()
    Dim i As Long
    Dim num As Long
    Dim sStr As String
    Dim myShapeRange As ShapeRange

    Set myShapeRange = Selection.ShapeRange

    With myShapeRange
    num = .Count
    ReDim mr(1 To num)

    For i = 1 To num
    sStr = .Item(i).Name
    mr(i) = Val(sStr)
    Next i
    End With

    End Sub
    '<<==================

    ---
    Regards,
    Norman



    "Harry" <Harry@discussions.microsoft.com> wrote in message
    news:67C76649-6445-4246-B0F3-55961F059C0C@microsoft.com...
    > I'm writing a macro that will rearrange a group of selected drawn
    > rectangles.
    > I need to select the rectangles and execute the macro which will modify an
    > array that contains the rectangle coordinates. The rectangles will be
    > deleted
    > and redrawn in their new positions. Stacking random boxes may be a better
    > way
    > to put it.
    >
    > capturing the selection gives me:
    >
    > ActiveSheet.Shapes.Range(Array(" 62", " 63", " 64", " 65" _
    > , " 66", " 67")).Select
    >
    > The macro i'm trying to execute is:
    >
    > Dim mr(100)
    >
    > With Selection
    > num = .Count ' return number of rectangles (this works)
    > for i = 1 to num
    > sr = .Item(i) ' this should return " 62" but it doesn't
    > need help here)
    > mr(i) = Val(sr)
    > Next i
    > End With
    >
    > Any help or ideas would be greatly appreciated.
    >
    > --
    > Best Regards,
    >
    > Harry




  3. #3
    Harry Guest

    Default Re: How do i read Selection.Shapes.Range(Array(i)?

    Norman,

    Thanks a million, it works like a charm!!

    --
    Best Regards,

    Harry


    "Norman Jones" wrote:

    > Hi Harry,
    >
    > The following worked for me:
    >
    > '==================>>
    > Public Sub Tester2()
    > Dim mr()
    > Dim i As Long
    > Dim num As Long
    > Dim sStr As String
    > Dim myShapeRange As ShapeRange
    >
    > Set myShapeRange = Selection.ShapeRange
    >
    > With myShapeRange
    > num = .Count
    > ReDim mr(1 To num)
    >
    > For i = 1 To num
    > sStr = .Item(i).Name
    > mr(i) = Val(sStr)
    > Next i
    > End With
    >
    > End Sub
    > '<<==================
    >
    > ---
    > Regards,
    > Norman
    >
    >
    >
    > "Harry" <Harry@discussions.microsoft.com> wrote in message
    > news:67C76649-6445-4246-B0F3-55961F059C0C@microsoft.com...
    > > I'm writing a macro that will rearrange a group of selected drawn
    > > rectangles.
    > > I need to select the rectangles and execute the macro which will modify an
    > > array that contains the rectangle coordinates. The rectangles will be
    > > deleted
    > > and redrawn in their new positions. Stacking random boxes may be a better
    > > way
    > > to put it.
    > >
    > > capturing the selection gives me:
    > >
    > > ActiveSheet.Shapes.Range(Array(" 62", " 63", " 64", " 65" _
    > > , " 66", " 67")).Select
    > >
    > > The macro i'm trying to execute is:
    > >
    > > Dim mr(100)
    > >
    > > With Selection
    > > num = .Count ' return number of rectangles (this works)
    > > for i = 1 to num
    > > sr = .Item(i) ' this should return " 62" but it doesn't
    > > need help here)
    > > mr(i) = Val(sr)
    > > Next i
    > > End With
    > >
    > > Any help or ideas would be greatly appreciated.
    > >
    > > --
    > > Best Regards,
    > >
    > > Harry

    >
    >
    >


Bookmarks

Posting Permissions

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