+ Reply to Thread
Results 1 to 7 of 7

How do I assign macro codes to multiple checkboxes

  1. #1
    Registered User
    Join Date
    01-11-2011
    Location
    cleveland ohio
    MS-Off Ver
    Excel 2007
    Posts
    16

    How do I assign macro codes to multiple checkboxes

    Hello, I have written my code already for my first check box. My goal is to click a checkbox, and it moves the data to the right. When Unchecked it(the macro) moves the data to where it was in the first place. Please see the code for checkbox 1 below.

    Please Login or Register  to view this content.
    I have about a 1000 checkboxes. I am trying to figure out a way to tell excel that I want the same code (different cells) for all my other checkboxes without me manually writing the code over and over again. I am using Excel 2007

    My next checkboxes when checked would have to move cell contents

    from K:7 to m7 and then back when unchecked
    from K:8 to m8
    from K:9 to m9 and so forth on so on all the way to 1000

    Thank you very much. Eagerly awaiting your response. I have spent half of my workday on this problem.
    Last edited by spamunch; 01-18-2011 at 02:58 PM.

  2. #2
    Forum Contributor
    Join Date
    08-21-2008
    Location
    Hamilton, New Zealand
    MS-Off Ver
    Office 2007
    Posts
    255

    Re: How do I assign macro codes to multiple checkboxes

    How about a slightly different approach ............

    Copy the follwing code into the sheet module in question.

    Please Login or Register  to view this content.
    This does not require the need to set-up the checkboxes and only requires a double-click in column A of any row. Change ActionCol value from 1 to column number where you require the checkbox & double-click to ocurr

  3. #3
    Registered User
    Join Date
    01-11-2011
    Location
    cleveland ohio
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: How do I assign macro codes to multiple checkboxes

    Hello wotadude. This looks very promising. I just looked at it now, I am playing around with it now to see how it works, I'll come back if I have any questions.

    Thanks again

  4. #4
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: How do I assign macro codes to multiple checkboxes

    Avoid 'copy' if you can.

    Please Login or Register  to view this content.
    or
    Please Login or Register  to view this content.
    Last edited by snb; 01-14-2011 at 09:29 AM.



  5. #5
    Registered User
    Join Date
    01-11-2011
    Location
    cleveland ohio
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: How do I assign macro codes to multiple checkboxes

    This is absolutely brilliant wotadude. I like doubleclicking and the checkboxes appear in the column. That is very good. However, I would prefer the end user clicks only once on the checkbox to move items and back. How do I do that?.

    Even as it stands this has given me hope, I had to code 600 checkboxes by hand yesterday and it was so exhausting. How can I learn to write VBA code like the one you have above?

  6. #6
    Registered User
    Join Date
    01-11-2011
    Location
    cleveland ohio
    MS-Off Ver
    Excel 2007
    Posts
    16

    Question Re: How do I assign macro codes to multiple checkboxes

    Please Login or Register  to view this content.
    Hello snb sorry I didn't see your post at first. Thank you for it. I'm not going to use checkboxes the way I did before. I am going to use wotadude's code as it is less time consuming than the way I did it before.

    I have a question though, In the code above, how do I select, copy and move multiple cells at the same time. I tried to do it this way (using range) it won't work.

    Please Login or Register  to view this content.
    Please see full code in wotadude's first post. Thank you
    Last edited by spamunch; 01-14-2011 at 11:19 AM.

  7. #7
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: How do I assign macro codes to multiple checkboxes

    You didn't read the second part of my post in which no checkbox is being used. You can doubleclick any cell in a row to swicth the cells in columns K and M

+ 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