E-mail Macro

lmusn89

New Member
Joined
Jul 7, 2014
Messages
4
Good afternoon,

I'm working on a Macro to email various POCs. Currently I've got one tab that I'm working off of, but ultimately I'd like to have multiple tabs and have the macro look for the data on each tab. Here's the code:

Sub Email()
Dim OutApp As Object
Dim OutMail As Object
Dim cell As Range
Application.ScreenUpdating = False
Set OutApp = CreateObject("Outlook.Application")
Dim strbody As String
For Each cell In Range("G1:G76")
strbody = strbody & cell.Value & vbNewLine
Next
On Error GoTo cleanup
For Each cell In Columns("A").Cells.SpecialCells(xlCellTypeConstants)
If LCase(Cells(cell.Row, "B").Value) = "yes" Then
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = "co@" & cell.Value & ".navy.mil"
.Cc = "xo@" & cell.Value & ".navy.mil"
.BCC = ""
.Subject = "DIVOs"
.Body = "Captain," & vbNewLine & vbNewLine & strbody
.Attachments.Add ("C:\Documents\Slates\Traditional Slate\Test.doc")
.Save
End With
On Error GoTo 0
Set OutMail = Nothing
End If
Next cell
cleanup:
Set OutApp = Nothing
Application.ScreenUpdating = True
End Sub

Ultimately, I'd like for this segment of the code:

For Each cell In Columns("A").Cells.SpecialCells(xlCellTypeConstants)
If LCase(Cells(cell.Row, "B").Value) = "yes" Then

to look on whatever tab I designate with multiple columns of ships for which I can put "yes" next to.

and this sgement of code:

For Each cell In Range("G1:G76")
strbody = strbody & cell.Value & vbNewLine

to be designated on a tab I designate.


Any help is greatly appreciated!
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

Forum statistics

Threads
1,223,911
Messages
6,175,325
Members
452,635
Latest member
laura12345

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