+ Reply to Thread
Results 1 to 6 of 6

Selecting an entire column minus two cells.

  1. #1
    Forum Contributor
    Join Date
    04-11-2011
    Location
    Columbus, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    325

    Selecting an entire column minus two cells.

    I am trying to swap columns of data at the click of a command button.

    I originally found this code to swap the columns.

    Please Login or Register  to view this content.
    However, when I try and swap a column that contains a command button I get an error. In my code is a sub Build_Menu. This is how I create my command buttons quickly. The function Create_Command_Button decides what the dimension of the button will be. Finally, the cmdButton4_Click was originally part of a command button in my real spreadsheet. Now it is just the code to swap two columns. When you select two columns at the top and run the sub it will swap the two areas. If you do the same thing in a column with a command button an error pops up.

    What I would like is for someone to show/ help me make the code so a user can select the columns and then have the code automatically not swap cells in row 1 or 2.

    Thank you in advance.
    Attached Files Attached Files
    Last edited by 111StepsAhead; 05-23-2011 at 09:24 AM.

  2. #2
    Forum Contributor Dave H9's Avatar
    Join Date
    03-10-2011
    Location
    Manchester, England
    MS-Off Ver
    Excel 2007
    Posts
    418

    Re: Selecting an entire column minus two cells.

    I can't get your code to run but you could try changing
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    04-11-2011
    Location
    Columbus, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    325

    Re: Selecting an entire column minus two cells.

    Yes, thank you Dave H9. That is what I was looking for a very long time. I am worried that the code didn't work for you though. Was it the swap code or the command button create code? In the file I gave you the command buttons are already created so if you try and create them again nothing will appear to change. There will just be two layers of command buttons.

  4. #4
    Forum Contributor Dave H9's Avatar
    Join Date
    03-10-2011
    Location
    Manchester, England
    MS-Off Ver
    Excel 2007
    Posts
    418

    Re: Selecting an entire column minus two cells.

    I'm glad it worked for you : ).

    Not running on mine is possibly due to my excel version but no worries as long as your sorted.

    Cheers

  5. #5
    Forum Contributor
    Join Date
    04-11-2011
    Location
    Columbus, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    325

    Re: Selecting an entire column minus two cells.

    Ahh, but what if I needed backwards compatibility some day? Not that I won't find out eventually when I get to testing but the less bugs I have now the easier my future will be. If you don't feel like bug hunting that is fine though. Have a nice Monday.

  6. #6
    Forum Contributor Dave H9's Avatar
    Join Date
    03-10-2011
    Location
    Manchester, England
    MS-Off Ver
    Excel 2007
    Posts
    418

    Re: Selecting an entire column minus two cells.

    OK, got it to work by transferring cmdButton4_click into a standard module. Your code does the column swap but bugs out at -

    Please Login or Register  to view this content.
    "Run-time 32809 - application defined or object defined error"

    I'm not sure what this bit of the code is trying to acheive!

+ 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