Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default PROB: Grouping Shapes With An Array Loop

Hello all,

Picture this;

A spreadsheet containing some shapes, the number and type of shape
varies with user operation. All have been renamed from their defaul
names when they were created.

I need to group together some of these shapes using VBA according t
their current names. This is where I have run into the problem o
transferring the array contents into a range.

Sub GroupShapes_v1()
Dim aryGroup() As String, shp As Shape, i As Integer

For Each shp In ActiveSheet.Shapes
If Left(shp.Name, 1) = "x" Then
ReDim Preserve aryGroup(i)
aryGroup(i) = shp.Name
i = i + 1
End If
Next shp

ActiveSheet.Shapes.Range(aryGroup).Select
Selection.ShapeRange.Group.Select

End Sub

However this generates an error at;
ActiveSheet.Shapes.Range(aryGroup).Select



So, I tried the following code after the For...Next loop instead

strGroup = Join(aryGroup, """,""")
ActiveSheet.Shapes.Range(Array(strGroup)).Select
Selection.ShapeRange.Group.Select

This then threw up an error at;
ActiveSheet.Shapes.Range(Array(strGroup)).Select



I think this would pose a similar problem to selecting multiple range
programmatically from a looped array.


Still no joy, but still confused.

Regards,

Boici

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Grouping Shapes With An Array Loop

Personally I find shaperanges a pita to work with. So, an end run:

Sub GroupShapes_v2()
Dim aryGroup() As String, shp As Shape, i As Integer
Dim ShapeStr As String
For Each shp In ActiveSheet.Shapes
If Left(shp.Name, 1) = "x" Then
ReDim Preserve aryGroup(i)
aryGroup(i) = shp.Name
i = i + 1
End If
Next shp
ActiveSheet.DrawingObjects(aryGroup).Select
End Sub


--
Jim Rech
Excel MVP


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default PROB: Grouping Shapes With An Array Loop

Aha! Managed to solve that one!

When looping through the shapes, it is possible to select multipl
items by using;

.Select False

instead of just;

.Select

which has the same effect as holding down the Ctrl button whil
selecting multiple shapes. e.g.



For Each shp In ActiveSheet.Shapes
If Left(shp.Name, 1) = "x" Then shp.Select False
Next shp

Selection.ShapeRange.Group.Select



Boici

--
Message posted from http://www.ExcelForum.com

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
duplicate an array and filter the list based on a grouping [email protected] Excel Worksheet Functions 7 June 20th 08 05:20 PM
Naming Auto Shapes and Creating new Shapes AL2000 Excel Discussion (Misc queries) 3 September 10th 07 04:12 AM
Shapes Range Array Bubb Excel Discussion (Misc queries) 1 April 10th 06 11:51 PM
Grouping Shapes MatP Excel Programming 1 November 20th 03 07:12 PM
Help -- Loop or Array? How to identify? zSplash Excel Programming 2 November 12th 03 05:05 AM


All times are GMT +1. The time now is 12:19 PM.

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

About Us

"It's about Microsoft Excel"