Hoping someone can help. I need an email to be generated based on data in multiple cells. Basically a range of cells.
Currently this is what I have:
Private Sub worksheet_change(ByVal Target As Range)
If Range("O6").Value = "X" Then
Call Mail_small_Text_Outlook
End If
End Sub
Sub Mail_small_Text_Outlook()
Dim xOutApp As Object
Dim xOutMail As Object
Dim xMailBody As String
Set xOutApp = CreateObject("Outlook.Application")
Set xOutMail = xOutApp.CreateItem(0)
xMailBody = "XXXX -" & vbNewLine & vbNewLine & _
" Request Ready for approval" & vbNewLine & _
Range("A6").Value & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & _
On Error Resume Next
With xOutMail
.To = "xxxxx@xxxxxx.com"
.CC = "xxxxxxx@xxxxxx.com"
.BCC = ""
.Subject = "PLEASE APPROVE: Request " & Range("A6").Value
.Body = xMailBody
.Display 'or use .Send
End With
On Error GoTo 0
Set xOutMail = Nothing
Set xOutApp = Nothing
End Sub
I can get this to work for one cell (O6), but I want this to include cells O6:O36. And then I also want the same for column P. My problem is getting this macro to work on multiple cells.
Someone please help, spent way too much time on this.
Currently this is what I have:
Private Sub worksheet_change(ByVal Target As Range)
If Range("O6").Value = "X" Then
Call Mail_small_Text_Outlook
End If
End Sub
Sub Mail_small_Text_Outlook()
Dim xOutApp As Object
Dim xOutMail As Object
Dim xMailBody As String
Set xOutApp = CreateObject("Outlook.Application")
Set xOutMail = xOutApp.CreateItem(0)
xMailBody = "XXXX -" & vbNewLine & vbNewLine & _
" Request Ready for approval" & vbNewLine & _
Range("A6").Value & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & _
On Error Resume Next
With xOutMail
.To = "xxxxx@xxxxxx.com"
.CC = "xxxxxxx@xxxxxx.com"
.BCC = ""
.Subject = "PLEASE APPROVE: Request " & Range("A6").Value
.Body = xMailBody
.Display 'or use .Send
End With
On Error GoTo 0
Set xOutMail = Nothing
Set xOutApp = Nothing
End Sub
I can get this to work for one cell (O6), but I want this to include cells O6:O36. And then I also want the same for column P. My problem is getting this macro to work on multiple cells.
Someone please help, spent way too much time on this.