+ Reply to Thread
Results 1 to 16 of 16

send email by checkbox selection

  1. #1
    Registered User
    Join Date
    05-09-2007
    Posts
    18

    send email by checkbox selection

    Hi I have the following code working, it pickups cell values then used them to make an email in outlook.

    What I would like to do is tick checkboxes to make a selection so that it can generate emails from only what I have selected. As i will be adding new IT Problems to a sheet and want to inform users of their problem number to tracking issues. How do i do this? thanks

    Please Login or Register  to view this content.

  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,258
    Hello Kendals,

    Use another macro to examine the state of the check boxes on the active sheet. Attach this macro to a command button (from the Forms toolbar) on the worksheet that has the check boxes. Click the command button when you want to send the emails. Here is the macro to do that. Place this in a Standard VBA module.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

  3. #3
    Registered User
    Join Date
    05-09-2007
    Posts
    18
    Hi I tried this but am unable to get it working.
    The email code is specific to one row, it needs to pickup the selected rows either by a checkbox or a value for example. I do see what you mean by checking the checkbox states then invoking the sendmail function, but i am unable to what you said working.

  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,258
    Hello Kendals,

    I'll post a sample workbook with a few check boxes so you can see how the code works. If the check box is in the same row as the email, it is easy do. You have to be careful of your check box alignment. If it isn't correct, it won't email.

    Sincerely,
    Leith Ross

  5. #5
    Registered User
    Join Date
    05-09-2007
    Posts
    18
    thanks, unless you can think of a better way to select them, maybe by entering the number 1 in a cell on each row, the code would pick this up and do the email. As i think the checkbox thing may get messy as the sheet that this code is going into is going to be used alot.

  6. #6
    Registered User
    Join Date
    07-03-2007
    Location
    Canberra, Australia
    MS-Off Ver
    2010
    Posts
    60
    Hi Kendals,

    I have used a similar idea but instead of check boxes I just entered 'Yes' or 'No' to send emails, the code i used was

    Please Login or Register  to view this content.
    Kerno

  7. #7
    Registered User
    Join Date
    05-09-2007
    Posts
    18
    how do i intergrate this in to my code?

  8. #8
    Registered User
    Join Date
    07-03-2007
    Location
    Canberra, Australia
    MS-Off Ver
    2010
    Posts
    60
    Try this

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    05-09-2007
    Posts
    18

    hi

    Hi Kerno,
    I got the code working by changing the range e2 so it looks for the yes field.
    One problem is after generating the emails from the yes selected ones, it generates the remaining ones as emails with no adress is, how do i add error checking in to stop this as this data rows would apply to the whole sheet.
    The code "For r = 2 To 8" sets the range of the rows for it to look in, which would be the whole sheet. Thank you for your help
    The below goes above the sendemail sub, incase you wanted to try it yourself
    Please Login or Register  to view this content.
    Heres my test sheet for your reference:
    http://aycu29.webshots.com/image/257...4145862_rs.jpg
    Last edited by kendals; 09-05-2007 at 07:58 AM.

  10. #10
    Registered User
    Join Date
    07-03-2007
    Location
    Canberra, Australia
    MS-Off Ver
    2010
    Posts
    60
    Hi,

    Try removing the for and next and just use the Do While
    Please Login or Register  to view this content.
    also you will need to add 'No' to the rows you do not want to send an email

  11. #11
    Registered User
    Join Date
    07-03-2007
    Location
    Canberra, Australia
    MS-Off Ver
    2010
    Posts
    60
    Hi,

    Try removing the for and next and just use the Do While
    Please Login or Register  to view this content.
    also you will need to add 'No' to the rows you do not want to send an email

  12. #12
    Registered User
    Join Date
    05-09-2007
    Posts
    18
    Hi i get runtime error 1004, below is the header which is placed above your code, if you run it you will see the error i get. I have a screen shot of my excel sheet above. The vba script works by picking up cell values and putting them in to an email.
    thanks
    Please Login or Register  to view this content.

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

    The following macro provides your SendEmail macro with error messages for the ShellExecute function. Taking short cuts when using API calls is common, and a bad idea. The API is not forgiving of errors like VBA. Place this code in a Standard VBA module.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

  14. #14
    Registered User
    Join Date
    05-09-2007
    Posts
    18
    thanks leith. Kerno do you know why i am getting the compile error?
    thanks

  15. #15
    Registered User
    Join Date
    07-03-2007
    Location
    Canberra, Australia
    MS-Off Ver
    2010
    Posts
    60
    Hi kendals

    Sorry for the late reply.
    Just replace the Cell references with Offsets, as below

    Please Login or Register  to view this content.

  16. #16
    Registered User
    Join Date
    11-24-2011
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: send email by checkbox selection

    Can you please add and excel 2003 attachment with working example. I have an excel with checkbox in every row. I want to send email notification with information's from the same row of the check box.

+ 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