combined sending data to a sheet and emailing sheet as attachment

Paul15

New Member
Joined
Jun 25, 2020
Messages
44
Office Version
  1. 2019
Platform
  1. Windows
Dear all,

I have a workbook with four sheets. My first sheet is a data entry sheet with 3 command buttons. Based upon certain data entry, one of these buttons is used to send the data to an Issues_Log sheet. My code works fine. What I wish to do at the same time as this Command Button macro runs is to additionally send the updated sheet, as an email attachment, in outlook, ideally this will prepopulate to email address, subject and basic text (Hi this is...). Is there someway to have a combined macro assigned to my button such that it updates the Issues_Log sheet firstly, then copies this sheet as an attachment and sends in a prepopulated Outlook mail. I have pasted my codes. Many thanks

VBA Code:
Sub SumbittoIssues_Log()



Application.ScreenUpdating = False

Dim wsCopy As Worksheet
Dim wsDest As Worksheet
Dim lCopyLastRow As Long
Dim lDestLastRow As Long

     
     'Set variables for copy and destination sheets
  Set wsCopy = Workbooks("HO_Daily_AssurancesWIP.xlsm").Worksheets("Daily_HO")
  Set wsDest = Workbooks("HO_Daily_AssurancesWIP.xlsm").Worksheets("Issues_Log")
  
    Worksheets("Daily_HO").Unprotect ("xxxx")
    Worksheets("Issues_Log").Unprotect ("xxxx")

    wsCopy.Range("C2:C5").Copy
    
    
        Sheets("Issues_Log").Cells(1, Columns.Count).End(xlToLeft).Offset(0, 1).PasteSpecial Paste:=xlPasteValues
    
    wsCopy.Range("D8:D24").Copy
    
     
     Sheets("Issues_Log").Cells(5, Columns.Count).End(xlToLeft).Offset(0, 1).PasteSpecial Paste:=xlPasteValues
     
    Worksheets("Daily_HO").Protect ("xxxx")
    Worksheets("Issues_Log").Unprotect ("xxxx")



   
    
MsgBox "Entry Submitted"



End Sub

Sub EmailIssues()



ActiveWorkbook.SendMail _

Recipients:=(Range("E5").Value), _

Subject:="*IMPORTANT - ISSUES*" & " - " & Range("A1") & " - " & Range("B3") & " - " & Range("B2")



MsgBox "Assurances Submitted - Issues Reported"



Application.DisplayAlerts = False





End Sub
VBA Code:
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Forum statistics

Threads
1,214,644
Messages
6,120,709
Members
448,983
Latest member
Joaquim_Baptista

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
Back
Top