Excel Emails

schugh

New Member
Joined
Apr 20, 2012
Messages
11
I have been previously helped by being directed to a site on excel emails, but i really dont have the program writting knowledge to convert what i see into what i want. Basically I have a table (made a simple version below) i have various orders but depending on teir status they may go on hold while awaiting things like customer information or an estimate approval, these are represented by various different "hold codes" the most important one is the "?" hold code.......sooo what I am looking for is the code for when a hold code changes to or from a "?" an email is sent stating the "customer name" and "serial number" and that it's hold code status has changed. Any help would be greatly appreciated.:confused:

Customer nameserial no.work scope hold code
A1OVERHAUL[
B2REPAIR[
C 3REPAIRE
D4REPAIR?
E5OVERHAUL?
F6OVERHAUL2
G7REPAIR8
H8REPAIR8

<tbody>
</tbody><colgroup><col><col><col><col><col></colgroup>




<tbody>
</tbody><colgroup><col><col span="4"></colgroup>
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Try this

Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
If Target.Column = 4 Then
    If Target.Value = "?" Then SendEmailUpdate Target.Offset(0, -3).Value, Target.Offset(0, -2).Value
End If
End Sub
Sub SendEmailUpdate(strCustName As String, strSN As String)
'Working in 2000-2010
'This example send the last saved version of the Activeworkbook
    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 = "[EMAIL="ron@debruin.nl"]ron@debruin.nl[/EMAIL]"
        .CC = ""
        .BCC = ""
        .Subject = "Something has changed"
        .Body = "Customer: " & strCustName & ", SN: " & strSN & " has changed to ?"
        .Display
'or use        .Send
    End With
    On Error GoTo 0
    Set OutMail = Nothing
    Set OutApp = Nothing
End Sub

Assume you know how to assign it to worksheet change?
Took the email part from Ron de Bruin Excel Automation
 
Upvote 0
Sorry my basic skills have failed me again, I can't seem to get it to work with the sample spreadsheet, I have entered the code but nothing happens when column 4 is changed to a "?", perhaps I don't know how to assign it to worksheet change after all.:oops:
 
Upvote 0
In the visual basic editor, upper left window which I think is called the project explorer, you can expand until you see the sheets of the target workbook. Right-click on the target ThisWorkbook and select "View Code". At the top left of that window is a drop-down that should say (General). Change that to (Workbook). The other drop-down up there should say SheetChange.

Actually, now that I think about it, the code would probably be better assigned to the target workSHEET. Right-click on the WorkSheet > View Code. Then dropdowns to (WorkSheet) and (SelectionChange). The first line of code would change from:
Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
To:
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,652
Messages
6,126,035
Members
449,281
Latest member
redwine77

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