group objects

jasman

Board Regular
Joined
Oct 30, 2010
Messages
141
Hi. I have the following code but i get erro 438 : Object doesnt support this property/method.

I have multiple pictures in the worksheet which on clicking the button i need to select all and group them. However the number of pictures changes all the time so i need to select all and cant specify an array.

Private Sub CommandButton2_Click()
Sheet2.Shapes.SelectAll
Selection.ShapeRange.Group.Select
End Sub
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
It's the Select that causes the error. Try:

Code:
Private Sub CommandButton2_Click()
    Sheet2.Shapes.SelectAll
    Selection.ShapeRange.Group
    Sheet2.Shapes(1).Select
End Sub
 
Upvote 0
Sorry, I can't reproduce your error. Can you group all the shapes manually?

Edit:

When I did it manually the macro recorder gave me:

Code:
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 25/02/2011 by Andrew
'
'
    ActiveSheet.DrawingObjects.Select
    Selection.ShapeRange.Group.Select
End Sub
 
Upvote 0
i got it to work with this:
Sheets("Sheet2").Select
ActiveSheet.Shapes.SelectAll
Selection.ShapeRange.Group.Select

thanks 4 help thou
 
Upvote 0

Forum statistics

Threads
1,224,566
Messages
6,179,558
Members
452,928
Latest member
101blockchains

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top