#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 163
Default Macro Help

I currently have an excel sheet with a button, when pressed it saves and
asked to select email addresses from another worksheet, when the user selects
the email addresses it will then email the relevant people to say this PIP is
ready for review.

Ideally, i would like to reference whatever is in E10 to lookup a
distribution group.

For example if the user types CURWEN into cell E10 it will look up Curwen
from a table within Excel and email whoever exists in the range of curwen.
This would be so much easier. Please help.

Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 921
Default Macro Help

Column A is for Email Addresses
Column B is for Subjects
Column C is for the body text of the email

This Code will send as many different emails to as many people as you like
by looping through the used range HTH.

Option Explicit

Public Sub MailTableItems()
Dim Outlook As Object
Dim Mail As Object
Dim Body As String
Dim i As Integer
Dim LastRow As Long
Dim ws As Worksheet

Set ws = ActiveWorkbook.Worksheets(1)
LastRow = ws.Cells(Rows.Count, 1).End(xlUp).Row

If LastRow = 1 Then MsgBox "No recipients were found", vbInformation

For i = 2 To LastRow
Set Outlook = CreateObject("Outlook.Application")
Outlook.Session.Logon
Set Mail = Outlook.CreateItem(0)

Body = ws.Range("C" & i).Value

On Error GoTo Morgue

With Mail
.To = ws.Range("A" & i).Value
.Subject = ws.Range("B" & i).Value
.Body = Body
.send
End With
Next

ErrorOut:
Set Outlook = Nothing
Set Mail = Nothing
Exit Sub

Morgue:
MsgBox Err.Description, vbCritical
Resume ErrorOut
End Sub



"Neil Holden" wrote:

I currently have an excel sheet with a button, when pressed it saves and
asked to select email addresses from another worksheet, when the user selects
the email addresses it will then email the relevant people to say this PIP is
ready for review.

Ideally, i would like to reference whatever is in E10 to lookup a
distribution group.

For example if the user types CURWEN into cell E10 it will look up Curwen
from a table within Excel and email whoever exists in the range of curwen.
This would be so much easier. Please help.

Thanks.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to copy and paste values (columns)I have a macro file built C02C04 Excel Programming 2 May 2nd 08 01:51 PM
AutoRun Macro with a delay to give user the choice to cancel the macro wanderlust Excel Programming 2 September 28th 07 04:09 PM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
macro to delete entire rows when column A is blank ...a quick macro vikram Excel Programming 4 May 3rd 04 08:45 PM
Start Macro / Stop Macro / Restart Macro Pete[_13_] Excel Programming 2 November 21st 03 05:04 PM


All times are GMT +1. The time now is 01:05 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"