+ Reply to Thread
Results 1 to 7 of 7

VBA to Move Shapes out of Defined Range

  1. #1
    Registered User
    Join Date
    10-14-2015
    Location
    East Coast
    MS-Off Ver
    2013
    Posts
    69

    VBA to Move Shapes out of Defined Range

    All,

    I've developed an application that essentially takes information within a table, and generates a number of textbox call-outs based upon the information within the table. The code below moves all overlapping shapes so they're no longer overlapping (works quite well). However, i'd like to also ensure that no shapes are covering a pre-defined (and static) range (collection of cells). Let's say i'd want to make sure no shapes overlap Range("E17:H30") of the activesheet. Any ideas here?

    Many thanks in advance!



    Please Login or Register  to view this content.

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,431

    Re: VBA to Move Shapes out of Defined Range

    What happens if you create a temporary shape that covers the cell range and then gets treated the same as all the other shapes?
    Does your algorithm position the callouts in a sensible way?
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    10-14-2015
    Location
    East Coast
    MS-Off Ver
    2013
    Posts
    69

    Re: VBA to Move Shapes out of Defined Range

    Hi Andy,

    Thanks for your quick reply. I've tried that and the script also moves the temporary shape out of the way of overlapping shapes, thus leaving exposed the range that i'd like to be uncovered.

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,431

    Re: VBA to Move Shapes out of Defined Range

    It looks like your looping will only compare shapes to the temporary one on the last iteration of the i loop. But it will move both shapes.
    If you reduce the loop then it will not be tested against any shapes.

    Can you post a small example and perhaps create a before and after so we can see how the shapes would be moved away from cells?

  5. #5
    Registered User
    Join Date
    10-14-2015
    Location
    East Coast
    MS-Off Ver
    2013
    Posts
    69

    Re: VBA to Move Shapes out of Defined Range

    Hi Andy,

    Sure thing. I've attached an unprotected sample workbook with instructions within.

    Thanks again for your quick feedback!
    Attached Files Attached Files

  6. #6
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,431

    Re: VBA to Move Shapes out of Defined Range

    Have a look at this.
    I have made some changes to the way the shapes are named so the code can tell which shapes are related.
    I have also named a local name to the RiskTemplate that defines the risk grid.

    Once the newly named callout textbox, line and dot have been added and run your overlap check it then checks against the named range.
    Depending on how messed up the callout become, when manualled moved, the clearing of grid may reintroduce callout overlap.

    Have you considered using the comments to hold this information?
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    10-14-2015
    Location
    East Coast
    MS-Off Ver
    2013
    Posts
    69

    Re: VBA to Move Shapes out of Defined Range

    Andy,

    This seems to work great. I hadn't considered your method of defining the grid.

    I have brought up your point regarding comments. That may be an easier route in the future.

    Thanks again for your help!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] If word entered not in defined name range, copy & paste it to bottom of defined name range
    By Butcher1 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-09-2014, 01:08 PM
  2. [SOLVED] insert Pre-defined text and hide shapes issue
    By crimzon in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-04-2014, 06:06 AM
  3. Different Display Scales move shapes
    By Steveapa in forum Excel General
    Replies: 3
    Last Post: 02-14-2014, 11:31 AM
  4. [SOLVED] Move Two Shapes In The Same Loop
    By primed in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-22-2014, 08:03 AM
  5. how to move excel shapes
    By jonelamora in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 07-24-2012, 10:45 PM
  6. Move Shapes to Grid in Excel
    By Environment in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-17-2011, 08:40 AM
  7. How To Move Shapes From Another Shapes? (floating shapes)
    By MarcLev in forum Word Programming / VBA / Macros
    Replies: 2
    Last Post: 10-04-2009, 04:04 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