Results 1 to 7 of 7

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

Threaded View

franksonata How to run a macro if... 02-02-2012, 12:15 PM
Leith Ross Re: How to run a macro if... 02-02-2012, 02:21 PM
franksonata Re: How to run a macro if... 02-03-2012, 05:29 AM
Leith Ross Re: How to run a macro if... 02-03-2012, 11:56 PM
franksonata Re: How to run a macro if... 02-06-2012, 06:01 AM
  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:

    'Email the worksheet to specified recipients LA'
    
        Dim OutApp As Object
        Dim OutMail As Object
        Dim cell As Range
        Dim strto As String
        
        On Error Resume Next
        
      
     For Each cell In ThisWorkbook.Sheets("SAP Access Request Form") _
     .Range("D66:D67").Cells.SpecialCells(xlCellTypeConstants)
     If cell.Value Like "?*@?*.?*" Then
     strto = strto & cell.Value & ";"
     End If
     Next cell
     On Error GoTo 0
     If Len(strto) > 0 Then strto = Left(strto, Len(strto) - 1)
             
    'Validation to choose which email route, validate checkboxes in range
    
    
    If Sheets("Sheet1").CheckBoxes("Check Box 1:Check Box10").Value = xlOn Then
    
    
    
      
    'Launches outlook to send following email LA
    
        Set OutApp = CreateObject("Outlook.Application")
        Set OutMail = OutApp.CreateItem(0)
    
        On Error Resume Next
        With OutMail
            .To = "email@email.co.uk"
            .CC = strto
            .BCC = ""
            .Subject = "Approval Required for SAP access"
            .Body = "Hi" & vbLf & vbLf & _
            "Please find attached a SAP user request form for your authorisation."
            .Attachments.Add ActiveWorkbook.FullName
            .Send
        End With
        On Error GoTo 0
    
        Set OutMail = Nothing
        Set OutApp = Nothing
              
              End If
        End If
        MsgBox "Thank you, your form has been sent to ."
        
    
    If Sheets("Sheet1").CheckBoxes("Check Box 11:Check Box21").Value = xlOn Then
    
    MsgBox "testing"
    Last edited by Leith Ross; 02-09-2012 at 01:58 PM. Reason: Removed Personal Info

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