Email Excel spreadsheet to people defined by user input

agb136

New Member
Joined
Jan 26, 2006
Messages
34
I have a simple problem, I think. I want to save a file and name it based on two cells and a timestamp. I got that working. Now I want the macro to email to myself (always) and the email addresses the user defines in the input box. I can get it to email me but I can not get the second part.

Here is my code:

Rich (BB code):
Sub Email()
    Dim wb1 As Workbook
    Dim wb2 As Workbook
    Dim wbname As String
    Dim a As String
    Dim b As String
    Dim EmailAddress As String
      
    Application.ScreenUpdating = False
    Set wb1 = ActiveWorkbook
    a = Range("B2")
    b = Range("F2")
    wbname = "C:/" & a & "-" & b & " " & _
    Format(Now, "mm-dd-yy h'mm") & ".xls"
    wb1.SaveCopyAs wbname
    Set wb2 = Workbooks.Open(wbname)
    
    With wb2
        EmailAddress = InputBox("Please enter the email addresses of the people you would like to send this file to: (Example: acb123@aol.com; acb132@yahoo.com; avb@gmail.com)")
        .SendMail "aaron918@aol.com" + "; " + EmailAddress, _
                  "Action Required: What If"
        .ChangeFileAccess xlReadOnly
        Kill .FullName
        .Close False
    End With
    Application.ScreenUpdating = True

End Sub

Thank you in advance for your help.

agb
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,168,126
Messages
5,857,523
Members
431,883
Latest member
Hien

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top