Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Sending mail to different mail address based on cell value

Hi

I need to add code to this below, basically, if a certain cell value = 00M
then send to one email address and if a certain cell value = 00C send to a
different email address.

An ideas?

Many thanks


Sub Email_Memo()
Range("B2:M34").Select
Selection.Copy
Workbooks.Add
ActiveSheet.Paste
Range("A1").Select
ActiveWindow.DisplayGridlines = False
ActiveWindow.Zoom = 75
With ActiveSheet.PageSetup
.PrintTitleRows = ""
.PrintTitleColumns = ""
End With
ActiveSheet.PageSetup.PrintArea = ""
With ActiveWindow
.DisplayHeadings = False
.DisplayHorizontalScrollBar = False
.DisplayVerticalScrollBar = False
.DisplayWorkbookTabs = False
End With
With ActiveSheet.PageSetup
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1
.PrintErrors = xlPrintErrorsDisplayed
End With
ActiveWorkbook.SendMail "),
("Memo From Sto ") & Sheets("Sheet1").Range("H4").Value
MsgBox "Your details have been sent", vbInformation, "PAYROLL MEMOS"
ActiveWindow.Close SaveChanges = True
Range("A1").Select

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default Sending mail to different mail address based on cell value

see below ....

"Duncan" wrote:

Hi

I need to add code to this below, basically, if a certain cell value = 00M
then send to one email address and if a certain cell value = 00C send to a
different email address.

An ideas?

Many thanks


Sub Email_Memo()
Range("B2:M34").Select
Selection.Copy
Workbooks.Add
ActiveSheet.Paste
Range("A1").Select
ActiveWindow.DisplayGridlines = False
ActiveWindow.Zoom = 75
With ActiveSheet.PageSetup
.PrintTitleRows = ""
.PrintTitleColumns = ""
End With
ActiveSheet.PageSetup.PrintArea = ""
With ActiveWindow
.DisplayHeadings = False
.DisplayHorizontalScrollBar = False
.DisplayVerticalScrollBar = False
.DisplayWorkbookTabs = False
End With
With ActiveSheet.PageSetup
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1
.PrintErrors = xlPrintErrorsDisplayed
End With


IF Worksheets("???").Range("???")="OOM" THEN

ActiveWorkbook.SendMail "),
("Memo From Sto ") & Sheets("Sheet1").Range("H4").Value


ELSEIF Worksheets("???").Range("???")="OOC" THEN

ActiveWorkbook.SendMail "),
("Memo From Sto ") & Sheets("Sheet1").Range("H4").Value


END IF


MsgBox "Your details have been sent", vbInformation, "PAYROLL MEMOS"
ActiveWindow.Close SaveChanges = True
Range("A1").Select

End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default Sending mail to different mail address based on cell value

double postiong - see my reply to your earlier ...

"Duncan" wrote:

Hi

I need to add code to this below, basically, if a certain cell value = 00M
then send to one email address and if a certain cell value = 00C send to a
different email address.

An ideas?

Many thanks


Sub Email_Memo()
Range("B2:M34").Select
Selection.Copy
Workbooks.Add
ActiveSheet.Paste
Range("A1").Select
ActiveWindow.DisplayGridlines = False
ActiveWindow.Zoom = 75
With ActiveSheet.PageSetup
.PrintTitleRows = ""
.PrintTitleColumns = ""
End With
ActiveSheet.PageSetup.PrintArea = ""
With ActiveWindow
.DisplayHeadings = False
.DisplayHorizontalScrollBar = False
.DisplayVerticalScrollBar = False
.DisplayWorkbookTabs = False
End With
With ActiveSheet.PageSetup
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1
.PrintErrors = xlPrintErrorsDisplayed
End With
ActiveWorkbook.SendMail "),
("Memo From Sto ") & Sheets("Sheet1").Range("H4").Value
MsgBox "Your details have been sent", vbInformation, "PAYROLL MEMOS"
ActiveWindow.Close SaveChanges = True
Range("A1").Select

End Sub

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Sending mail to different mail address based on cell value

You could also set up string variable at the beginning of your procedu

Dim strRecipient As String
If Range("Z1").Text = "00M" Then
strRecipient = "
ElseIf Range("Z1").Text = "00C" Then
strRecipient = "
End If

And then modify the send mail line:

ActiveWorkbook.SendMail strRecipient, _
("Memo From Sto ") & Sheets("Sheet1").Range("H4").Value


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
Changing From Address before sending mail navin Excel Programming 0 January 15th 09 09:27 AM
E-Mail attachment to same e-mail address in Outlook Vick Excel Discussion (Misc queries) 4 May 17th 07 07:53 PM
E-mail to every e-mail address in an Excel column? MrMan&Fam Excel Discussion (Misc queries) 24 July 19th 06 09:35 AM
General mail failure when sending e-mail from Excel Adrienne Excel Discussion (Misc queries) 5 November 4th 05 12:59 PM


All times are GMT +1. The time now is 04:51 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"