Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 71
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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default 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" wrote in message
...
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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 71
Default 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" wrote in message
...
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




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Shapes Range Array Bubb Excel Discussion (Misc queries) 1 April 10th 06 11:51 PM
Programmatically add shapes to a selection Edward Ulle Excel Programming 3 August 8th 05 12:17 AM
Programmatically add shapes to a selection Edward Ulle Excel Programming 0 June 1st 05 08:29 PM
Read a range to an array Microsoft Forum Excel Programming 4 January 23rd 05 05:23 PM
Read Range Data into Array Stratuser Excel Programming 1 April 26th 04 06:46 PM


All times are GMT +1. The time now is 09:27 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"