I have this code I found and altered it for my use.
My requirement was to select every shape but a button linked to the macro and group them together since the number of shapes can change with what I select in my excel sheet (It creates a collated diagram).
Dim vShapesToExclude As Variant
Dim aShapesToSelect() As String
Dim oShape As Shape
Dim vMatchVal As Variant
Dim ShpCnt As Integer: ShpCnt = 0
vShapesToExclude = Array("Button 1")
ReDim aShapesToSelect(1 To ActiveSheet.Shapes.count)
For Each oShape In ActiveSheet.Shapes
vMatchVal = Application.Match(oShape.Name, vShapesToExclude, 0)
If IsError(vMatchVal) Then
ShpCnt = ShpCnt + 1
aShapesToSelect(ShpCnt) = oShape.Name
End If
Next oShape
ActiveSheet.Shapes.Range(aShapesToSelect()).Select
ActiveSheet.Shapes.Range(aShapesToSelect()).Group
This works fine if I change nothing in the excel sheet but the moment I click on my drop down box, and I don't even need to change anything, it breaks giving me the classic 1004 error.
I had a look into what was causing this with "debug.print" on the "aShapesToSelect" array thinking maybe something was empty, instead I'm met with a log of "Drop down" instead of "textbox" causing the issues.
I have absolutely no idea what is causing the switch over and I can only get it working again if I recompile the code to "reset" the selection.
Any assistance is appreciated, thanks.
Bookmarks