Results 1 to 7 of 7

VBA - Grouping Shapes & Deleting Them

Threaded View

CUCE VBA - Grouping Shapes &... 11-03-2020, 04:39 PM
Norie Re: VBA - Grouping Shapes &... 11-03-2020, 04:57 PM
CUCE Re: VBA - Grouping Shapes &... 11-03-2020, 05:04 PM
Norie Re: VBA - Grouping Shapes &... 11-03-2020, 05:43 PM
CUCE Re: VBA - Grouping Shapes &... 11-03-2020, 05:53 PM
Norie Re: VBA - Grouping Shapes &... 11-03-2020, 06:07 PM
CUCE Re: VBA - Grouping Shapes &... 11-03-2020, 06:39 PM
  1. #1
    Registered User
    Join Date
    11-03-2020
    Location
    Colorado
    MS-Off Ver
    Office 365
    Posts
    6

    VBA - Grouping Shapes & Deleting Them

    I already have a macro that will draw up to 36 shapes (combo of ovals and freeforms) all on a range I call "DrawRange". I am trying to add to this to group all the shapes so that a user can move/manipulate the drawing easily. And I would like to also be able to delete this shape, via VBA, in the event of a "re-draw" event initiated by a user.

    The code I have currently for the group is similar to delete so we'll just focus on that. Here is what I have:

    Sub GroupShapes()
    Dim shp As Shape
    Dim r As Range
    Set r = Range("DrawRange")
    For Each shp In ActiveSheet.Shapes
     If Not Intersect(shp.TopLeftCell, r) Is Nothing Then
     shp.Select Replace:=False
     End If
    Next shp
    Selection.Group
    End Sub
    This works... sometimes. However often enough I get an error "Application-Defined or Object Defined Error" listed on the "Not Intersect" line. I'm not sure what I'm being told in that error message nor how to go about fixing it. Any help is greatly appreciated.

    And for anyone interested, the delete routine is similar to above except after the Not Intersect line, I use "shp.delete".

    Thank you
    Last edited by CUCE; 11-03-2020 at 06:39 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Grouping charts and shapes programatically
    By tonyd5 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-23-2018, 03:38 AM
  2. [SOLVED] Shapes and Deleting Shapes
    By rob_h in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-24-2017, 10:07 AM
  3. VBA grouping shapes by position
    By bluphoto in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-19-2014, 01:23 PM
  4. Need help with grouping shapes using an array
    By plucier in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-13-2013, 12:22 AM
  5. checking if shapes exist and grouping them
    By gummi in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-21-2008, 11:12 AM
  6. Grouping Shapes
    By LaraBee in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 12-14-2007, 03:55 PM
  7. Deleting Shapes
    By aftamath in forum Excel General
    Replies: 5
    Last Post: 11-04-2005, 08:45 PM

Tags for this Thread

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1