PDA

View Full Version : VB Code partially working



gcmax
04-25-2013, 05:51 AM
Hello,

I am trying to capture the edits only from a workbook and then email them as a single sheet attachment but the code I have just emails the whole workbook so I don't know what has been changed!



Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
If Not Application.Intersect(Range("A1:O200"), Target) Is Nothing Then

If Target.Value = "0" Then
'if cell in "M" = 0 run the macro
str = Cells(Target.Row, "M").Value

Sub Mail_Workbook_1()
Dim OutApp As Object
Dim OutMail As Object

Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)

On Error Resume Next
With OutMail
.To = "steven@bellsdomestics.co.uk"
.CC = ""
.BCC = ""
.Subject = "The stock has been updated"
.Body = "Bells Stock Updated"
.Attachments.Add ActiveWorkbook.FullName
.Send
End With
On Error GoTo 0

Set OutMail = Nothing
Set OutApp = Nothing
End Sub

SamT
04-25-2013, 09:36 AM
This will attach the entire bokk for which ever book you are in when you run the macro

Sub Mail_Workbook_1()
.
.
.
.Attachments.Add ActiveWorkbook.FullName