Macro needed to email based on data in cell

jjhags56

New Member
Joined
Jan 22, 2018
Messages
1
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.
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

Forum statistics

Threads
1,216,124
Messages
6,128,993
Members
449,480
Latest member
yesitisasport

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