jubilee101
New Member
- Joined
- Apr 17, 2013
- Messages
- 25
Hi Everyone,
I have an Excel tracker. I need to send an email once a particular cell is click. I have the email bit working but not the cell click action.
Email code is:
Then for the cell click, I have: (Doesn't work - not sure how to link them either
I have an Excel tracker. I need to send an email once a particular cell is click. I have the email bit working but not the cell click action.
Email code is:
Code:
Sub CreateMail()
Dim objOutlook As Object
Dim objMail As Object
Dim rngTo As Range
Dim rngSub As Range
Dim rngMessage As Range
Dim rngAttachment As Range
Set objOutlook = CreateObject("Outlook.Application")
Set objMail = objOutlook.CreateItem(0)
With ActiveSheet
Set rngTo = .Range("H4")
Set rngSub = .Range("I4")
Set rngMessage = .Range("J4")
Set rngAttachment = .Range("K4")
End With
With objMail
.To = rngTo.Value
.Subject = rngSub.Value
.Body = rngMessage.Value
.Attachments.Add rngAttachment.Value
.Display 'Instead of .Display, you can use .Send to send the email
End With
Set objOutlook = Nothing
Set objMail = Nothing
Set rngTo = Nothing
Set rngSub = Nothing
Set rngMessage = Nothing
Set rngAttachment = Nothing
End Sub
Then for the cell click, I have: (Doesn't work - not sure how to link them either
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Intersect(Target, Range("L4:L1000")) Is Nothing Then
Exit Sub
Else
Sheet1.CreateMail
End If
End Sub
Last edited: