+ Reply to Thread
Results 1 to 6 of 6

Use one command button to 3 check boxes with different call macros

  1. #1
    Forum Contributor
    Join Date
    07-28-2012
    Location
    madrid
    MS-Off Ver
    Excel 2010 at work excel 2016
    Posts
    1,102

    Use one command button to 3 check boxes with different call macros

    Hi i have a little problem. I have 3 check boxes, with 3 different macro attached. I have made so i can only tick one check box at a time.
    So when i tick the first checkbox one. the commandbutton will run the macro for that one attached.
    But i cant make it work.
    If i put these 3 codes one by one. It works fine. But if i try put them together i get an error.
    My 3 codes are like this.

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    So i want to use the same button (commandbutton1)

    But here with 3 different macro attached to each checkbox
    Checkbox1 = i Call SetWorksheet1
    Checkbox2 = i Call SetWorksheet2
    Checkbox3 = i Call SetWorksheet3

    Please have a look and see what can be done, i feel little stucked now.

    Thanks in advanc
    Abjac

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    There shouldn't be a problem if you combine the 3 subs.

    What happens when you try it?

    Keeping them separate will actually cause an error.
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    07-28-2012
    Location
    madrid
    MS-Off Ver
    Excel 2010 at work excel 2016
    Posts
    1,102

    Re: Use one command button to 3 check boxes with different call macros

    HI Norie.
    I have tried. When i run them seperately its just to try if all options individual was working. I tried this code with them together but maybe i just put them together wrong, or i am sure i do smile. This was what i tried.
    But it come up with an error. I have made so when you tick one of the checkboxes, the other 2 are disabled.

    When i take below code it only work on checkbox1 and call SetWorksheet1

    Please see if you can make this one work

    Thanks in advance
    Abjac

    Please Login or Register  to view this content.
    Last edited by abjac; 11-04-2012 at 09:37 AM.

  4. #4
    Valued Forum Contributor
    Join Date
    02-12-2011
    Location
    The Netherlands
    MS-Off Ver
    365
    Posts
    818

    Re: Use one command button to 3 check boxes with different call macros

    Try it once Abjac.
    Please Login or Register  to view this content.
    Kind regards, Harry.

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Use one command button to 3 check boxes with different call macros

    The If End If's should be separate, not nested.

    HSV has posted one way of doing it.

    By the way, why checkboxes? If you used option buttons there could only ever be one selected.

  6. #6
    Forum Contributor
    Join Date
    07-28-2012
    Location
    madrid
    MS-Off Ver
    Excel 2010 at work excel 2016
    Posts
    1,102

    Re: Use one command button to 3 check boxes with different call macros

    HI Norie. This is working. I am smiling of my self, i didnt see this one. But its working. Yes i know options boxes, could be a possibility. But its the first time i use check boxes also. But this is great, thanks alot Norie. Have a nice day

    Abjac

+ 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