+ Reply to Thread
Results 1 to 7 of 7

How to run a macro if checkboxes are checked in a range

  1. #1
    Registered User
    Join Date
    02-02-2012
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    5

    How to run a macro if checkboxes are checked in a range

    Hi All,

    I am trying to configure a button on an excel sheet to send the populated sheet to 2 different recipients. The recipient the email goes to will be dependant on whether a checkbox/ multiple checkboxes in a range are ticked.

    At present the sheet I have set up has 2 buttons and requires the user to determine which to press for the email with attached sheet to be sent.

    However my boss wants this consolidated into one button which covers all actions. I am sure this is possible, but at the moment it seems to be beyond my abilities.

    Simply put:

    If checkboxes 1:10 , 22:26 are checked

    attach file and send email to recipient

    else

    if checkboxes 11:21 are checked

    attach file and send email to recipient




    Current code:

    Please Login or Register  to view this content.
    Last edited by Leith Ross; 02-09-2012 at 01:58 PM. Reason: Removed Personal Info

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: How to run a macro if checkboxes are checked in a range

    Hello franksonata,

    Welcome to the Forum!

    I made a few changes to the macro. It checks which check boxes are set and decides if the email is to sent or not. The assumption is these are Forms check boxes and not ActiveX.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    02-02-2012
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: How to run a macro if checkboxes are checked in a range

    Thank you so much for your response Leith, these are in fact Active X check boxes, apologies I should have stated this. Will this cause much of an issue?

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: How to run a macro if checkboxes are checked in a range

    Hello Frank,

    The ActiveX check boxes are accessed in a different manner than the Forms type. Here is the code for the ActiveX check boxes.

    I noticed in your original post that check boxes 1 through 26 all have to be checked. This version of the macro checks that all 26 are checked. I can change the macro to do different actions based on which check boxes are set if needed. Let me know if you do.
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    02-02-2012
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: How to run a macro if checkboxes are checked in a range

    Thanks again Leith for your quick response. My code should have read if any check boxes are checked in a particular range.

    If any check boxes are checked in range 11-21 then the email needs to be generated and sent to a different address, I have not included this in the code, as needed to sort out check box issue first, I think that is the last caveat!

    code as is with your amendments, including additional required 'code'
    Please Login or Register  to view this content.
    Last edited by Leith Ross; 02-09-2012 at 02:00 PM. Reason: Removed Personal info

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: How to run a macro if checkboxes are checked in a range

    Hello Frank,

    This revision of the macro should be fine. Just change the second email address from "a@differentemailaddress.co.uk" to the real one before you run it. It is marked in bold below.
    Please Login or Register  to view this content.
    Last edited by Leith Ross; 02-09-2012 at 02:01 PM. Reason: Removed Personal Info

  7. #7
    Registered User
    Join Date
    02-02-2012
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: How to run a macro if checkboxes are checked in a range

    Thank you so much for your time Leith, this is perfect.

+ 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