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 to email different email address based on cell value

Hi

I have the code below working for me, to copy a sheet to a blank workbook
and email just this sheet.

However I need to add something to it, so if a certain cell value = 00M send
to one particular email address and if the cell value = 00C send to a
different email address.

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 to email different email address based on cell value

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




"Duncan" wrote:

Hi

I have the code below working for me, to copy a sheet to a blank workbook
and email just this sheet.

However I need to add something to it, so if a certain cell value = 00M send
to one particular email address and if the cell value = 00C send to a
different email address.

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

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

That works great. Thanks for that.

"Patrick Molloy" wrote:

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




"Duncan" wrote:

Hi

I have the code below working for me, to copy a sheet to a blank workbook
and email just this sheet.

However I need to add something to it, so if a certain cell value = 00M send
to one particular email address and if the cell value = 00C send to a
different email address.

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: 1,298
Default Sending to email different email address based on cell value

thats Ok - a bit rough ... but see arjen's reply --- nice and tidy when you
have the time :)

"Duncan" wrote:

That works great. Thanks for that.

"Patrick Molloy" wrote:

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




"Duncan" wrote:

Hi

I have the code below working for me, to copy a sheet to a blank workbook
and email just this sheet.

However I need to add something to it, so if a certain cell value = 00M send
to one particular email address and if the cell value = 00C send to a
different email address.

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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Sending to email different email address based on cell value

If Range("E14") = "" Then
MsgBox "A Pay Group Must Be Entered"

At the start of the code, I have entered the above to check that the Pay
Group is entered, and if not display a message box.

How do i then stop the code from continuing as it is doing now, if there is
no pay grup entered
Cheers
Duncan

"Patrick Molloy" wrote:

thats Ok - a bit rough ... but see arjen's reply --- nice and tidy when you
have the time :)

"Duncan" wrote:

That works great. Thanks for that.

"Patrick Molloy" wrote:

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




"Duncan" wrote:

Hi

I have the code below working for me, to copy a sheet to a blank workbook
and email just this sheet.

However I need to add something to it, so if a certain cell value = 00M send
to one particular email address and if the cell value = 00C send to a
different email address.

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

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 for Email - Sending to email addresses in cell Brice Excel Programming 2 January 26th 09 07:28 AM
Sending Email to non-standard address using CDO? [email protected] Excel Programming 0 February 11th 08 10:40 PM
sending email based on cell condition jbly Excel Discussion (Misc queries) 1 January 4th 08 08:03 PM
Excel spreadsheet sending email based on cell formula [email protected] Excel Worksheet Functions 1 January 29th 07 02:16 PM
Sending email via VB - address length Carl Woodall Excel Programming 3 January 22nd 04 05:08 PM


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