+ Reply to Thread
Results 1 to 4 of 4

Using CommandButtons to move rows

  1. #1
    Registered User
    Join Date
    06-30-2009
    Location
    Southern California, Earth
    MS-Off Ver
    Excel 2010
    Posts
    72

    Talking Using CommandButtons to move rows

    This may be a terrible way of doing this, but I will try to explain and hopefully get some better direction. What I am trying to create is something that is easy to use and will allow the user to move people up and down on a list by clicking an up or down arrow (CommandButton). There are two CommandButtons per row, one in column A and one in column B. Clicking on the Down button on the first row for instance, replaces the range C2:H2 with C3:H3.

    What I do not currently understand is a dynamic way of doing this. Surely I wouldn't have to replicate code for each button would I? I would like for this to be about a list of 30 people (rows) or so. I would appreciate any or all help.

    Please Login or Register  to view this content.
    Regards,
    Hoffey
    Last edited by hoffey; 10-07-2010 at 04:53 PM.

  2. #2
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Using CommandButtons to move rows

    I'm sure there's a better approach, but this works.
    Copy the entire code below into a standard module.
    Create two buttons or shapes and assign the macro appropriately.

    Please Login or Register  to view this content.
    Last edited by Palmetto; 09-30-2010 at 12:17 PM.
    Palmetto

    Do you know . . . ?

    You can leave feedback and add to the reputation of all who contributed a helpful response to your solution by clicking the star icon located at the left in one of their post in this thread.

  3. #3
    Forum Contributor
    Join Date
    07-07-2005
    Location
    England
    MS-Off Ver
    Office 2019 Enterprise
    Posts
    462

    Re: Using CommandButtons to move rows

    Probably a better way but this is how I would do it.

    Please Login or Register  to view this content.
    User must select cell in left hand side of range (So if you want to move cells D12:E12 then they must select D12.

    You'll need to make it idiot proof (Put warnings in if user is trying to move a cell above row 1 etc..

    Hope that helps

    John

  4. #4
    Registered User
    Join Date
    06-30-2009
    Location
    Southern California, Earth
    MS-Off Ver
    Excel 2010
    Posts
    72

    Re: Using CommandButtons to move rows

    Thanks guys, I really appreciate it. In the end I changed approaches on how to handle the data. This is good for future reference however.

    Regards,
    Hoffey

+ 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