OK, so I have been struggling with this problem for some time. I am fairly new to VBA so bear with me.
What I need my program to do is to grab the cell values in my workbook that were updated and push the data to an email. Let's say my range I want to watch is A4:A100. A user puts in a sales order number into A10 and A11. I need my program to take the values from those cells and insert them into an email when the workbook is saved. I already have the code at the end of this question that emails a list of people when the workbook is saved. Basically I would very much like to have this email contain the ID's (Column A) of records that were entered. Thank you for your help.
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel As Boolean)
Dim answer As String
answer = MsgBox("Would you like to save and email a notification?", vbYesNo, "Save and Email")
If answer = vbNo Then Cancel = True
If answer = vbYes Then
'open outlook type stuff
Set OutlookApp = CreateObject("Outlook.Application")
Set OlObjects = OutlookApp.GetNamespace("MAPI")
Set newmsg = OutlookApp.CreateItem(olMailItem)
'add recipients
newmsg.Recipients.Add ("[email protected]")
newmsg.Recipients.Add ("[email protected]")
'add subject
newmsg.Subject = "Update on CREDIT HOLD list"
'add body
newmsg.Body = "Please check the Credit Hold excel file on the S drive for updates."
newmsg.Display 'display
newmsg.Send 'send message
'give conformation of sent message
MsgBox "File saved and messages sent.", , "Saved and Sent"
End If
'save the document
'Me.Worksheets.Save
End Sub
Range("A20:A21").Copy
and then corresponding code to paste into Outlook. I don't know Outlook off the of my head. – Byron Wall