+ Reply to Thread
Results 1 to 13 of 13

Moving Shapes Incrementally

  1. #1
    Registered User
    Join Date
    12-05-2010
    Location
    LA, CA
    MS-Off Ver
    Excel 2010
    Posts
    59

    Moving Shapes Incrementally

    Hi,
    I need some help writing a macro that will move a shape incrementally. For example, I have a rectangle that I want to move 10 pts to the right every time I run the macro. So, if I have a rectangle in Position 1, when I run the macro, it will move 10 pts to the right to Position 2. If I run the macro again, it will move another 10 pts to the right of Position 2, and so on.

    Right now, I have a macro that will only move the rectangle to a permanently spot-- I can't seem to get it to move incrementally.

    Can someone help me?

    Thanks!
    Jane
    Last edited by janeml; 12-06-2010 at 05:56 PM.

  2. #2
    Forum Contributor
    Join Date
    02-19-2005
    Location
    Gurgaon,India
    MS-Off Ver
    2007,2010,2013
    Posts
    180

    Re: Moving Shapes Incrementally

    Hi,

    try

    Please Login or Register  to view this content.
    HTH
    Kris

  3. #3
    Registered User
    Join Date
    12-05-2010
    Location
    LA, CA
    MS-Off Ver
    Excel 2010
    Posts
    59

    Re: Moving Shapes Incrementally

    Thanks! it works great!

  4. #4
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Moving Shapes Incrementally

    Kris,
    Out of curiosity why use the AlternativeText property if you're just going to store the Left value in it? It could be very confusing for a user if they move a shape manually in between iterations of that macro.
    Last edited by romperstomper; 12-06-2010 at 03:55 AM.
    Remember what the dormouse said
    Feed your head

  5. #5
    Forum Contributor
    Join Date
    02-19-2005
    Location
    Gurgaon,India
    MS-Off Ver
    2007,2010,2013
    Posts
    180

    Re: Moving Shapes Incrementally

    Good point.

    this should suffice.

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    12-05-2010
    Location
    LA, CA
    MS-Off Ver
    Excel 2010
    Posts
    59

    Re: Moving Shapes Incrementally

    Thanks Kris!

    One more question-- how can I get my macro to loop through all the worksheets in my workbook for the same main task below? I googled some macro codes but I haven't been able to find something that works-- below is a code I tried:
    Please Login or Register  to view this content.
    Last edited by romperstomper; 12-06-2010 at 02:26 PM.

  7. #7
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Moving Shapes Incrementally

    Replace Activesheet with ws in your code, and move the constant declaration to the start of your sub.

    Note: when posting code, please use code tags as per the forum rules. I have added them for you on this occasion.
    Last edited by romperstomper; 12-06-2010 at 02:31 PM.

  8. #8
    Registered User
    Join Date
    12-05-2010
    Location
    LA, CA
    MS-Off Ver
    Excel 2010
    Posts
    59

    Re: Moving Shapes Incrementally

    Thanks for updating my code.

    Changing Activesheet to ws didn't seem to do the trick... unless I'm missing something? I get an "The Item with the specified name wasn't found." error. Below is my updated code per recommendation:

    Please Login or Register  to view this content.

  9. #9
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Moving Shapes Incrementally

    Then you don't have a shape called Rectangle1 on each sheet, so how should the code determine what to move?

  10. #10
    Registered User
    Join Date
    12-05-2010
    Location
    LA, CA
    MS-Off Ver
    Excel 2010
    Posts
    59

    Re: Moving Shapes Incrementally

    I do have a shape named Rectangle 1. I tried the same code on a completely blank worksheet, and the rectangle on both tabs do move over, however, the error still appears.

    Thanks.

  11. #11
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Moving Shapes Incrementally

    Do ALL the sheets have this rectangle?

  12. #12
    Registered User
    Join Date
    12-05-2010
    Location
    LA, CA
    MS-Off Ver
    Excel 2010
    Posts
    59

    Re: Moving Shapes Incrementally

    Quote Originally Posted by romperstomper View Post
    Do ALL the sheets have this rectangle?
    I got it to work. Thanks for pointing out about the ALL sheets. I had two extra sheets, one with a large data dump and another for user inputs. Those two tabs didn't have the rectangle.

  13. #13
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Moving Shapes Incrementally

    Glad to help.

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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