Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Help needed with the following macro


The following macro i borrowed from somewhere else. I modified it to fit
my needs but I need to add a feature to it. Namely, this macro filters
an Excel file and sends filtered part to a person in a file by using my
email. I would like this macro to add a generic message to the email
with the attached file. How can I add an argument that would
insert/paste a text in the body of email message.
Please post your suggestions or email me at

Thanks.


Sub Distribute()
'Public Sub SendItAll()
' Clear out any old data on Report
Sheets("Contract Expiration Report").Select
Range("A1").CurrentRegion.ClearContents
' Sort data by region
Sheets("Data").Select
Range("A1").CurrentRegion.Select
Selection.Sort Key1:=Range("A2"), Header:=xlYes
' Process each record on Distribution
Sheets("CST Distribution List").Select
FinalRow = Range("A15000").End(xlUp).Row
For i = 2 To FinalRow
Sheets("CST Distribution List").Select
RegionToGet = Range("A" & i).Value
Recipient = Range("B" & i).Value
' Clear out any old data on Report
Sheets("Contract Expiration Report").Select
Range("A1").CurrentRegion.ClearContents
' Get records from Data
Sheets("Data").Select
Range("A1").CurrentRegion.Select
' Turn on AutoFilter, if it is not on
If ActiveSheet.AutoFilterMode = False Then
Selection.AutoFilter
' Filter the data to just this region
Selection.AutoFilter Field:=1, Criteria1:=RegionToGet
' Select only the visible cells and copy to Report
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Copy Destination:=Sheets("Contract Expiration
Report").Range("A1")
' Turn off the Autofilter
Selection.AutoFilter
' Copy the Report sheet to a new book and e-mail
Sheets("Contract Expiration Report").Copy
Application.Dialogs(xlDialogSendMail).Show _
*arg1:=Recipient, _
arg2:="Contract pricing expiration report for " &
RegionToGet*
ActiveWorkbook.Close SaveChanges:=False
Next i
End Sub


--
stric
------------------------------------------------------------------------
stric's Profile:
http://www.excelforum.com/member.php...o&userid=25230
View this thread: http://www.excelforum.com/showthread...hreadid=387195

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Help needed with the following macro

The help for xlDialogSendMail seems to suggest that there is no body
argument, just recipient, subject and return_receipt.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"stric" wrote in
message ...

The following macro i borrowed from somewhere else. I modified it to fit
my needs but I need to add a feature to it. Namely, this macro filters
an Excel file and sends filtered part to a person in a file by using my
email. I would like this macro to add a generic message to the email
with the attached file. How can I add an argument that would
insert/paste a text in the body of email message.
Please post your suggestions or email me at

Thanks.


Sub Distribute()
'Public Sub SendItAll()
' Clear out any old data on Report
Sheets("Contract Expiration Report").Select
Range("A1").CurrentRegion.ClearContents
' Sort data by region
Sheets("Data").Select
Range("A1").CurrentRegion.Select
Selection.Sort Key1:=Range("A2"), Header:=xlYes
' Process each record on Distribution
Sheets("CST Distribution List").Select
FinalRow = Range("A15000").End(xlUp).Row
For i = 2 To FinalRow
Sheets("CST Distribution List").Select
RegionToGet = Range("A" & i).Value
Recipient = Range("B" & i).Value
' Clear out any old data on Report
Sheets("Contract Expiration Report").Select
Range("A1").CurrentRegion.ClearContents
' Get records from Data
Sheets("Data").Select
Range("A1").CurrentRegion.Select
' Turn on AutoFilter, if it is not on
If ActiveSheet.AutoFilterMode = False Then
Selection.AutoFilter
' Filter the data to just this region
Selection.AutoFilter Field:=1, Criteria1:=RegionToGet
' Select only the visible cells and copy to Report
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Copy Destination:=Sheets("Contract Expiration
Report").Range("A1")
' Turn off the Autofilter
Selection.AutoFilter
' Copy the Report sheet to a new book and e-mail
Sheets("Contract Expiration Report").Copy
Application.Dialogs(xlDialogSendMail).Show _
*arg1:=Recipient, _
arg2:="Contract pricing expiration report for " &
RegionToGet*
ActiveWorkbook.Close SaveChanges:=False
Next i
End Sub


--
stric
------------------------------------------------------------------------
stric's Profile:

http://www.excelforum.com/member.php...o&userid=25230
View this thread: http://www.excelforum.com/showthread...hreadid=387195



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 help needed Carolina Girl[_2_] Excel Worksheet Functions 1 March 24th 09 04:50 PM
Macro help needed James Excel Worksheet Functions 1 February 22nd 08 01:03 PM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
Macro needed to Paste Values and prevent Macro operation thunderfoot Excel Discussion (Misc queries) 1 June 11th 05 12:44 AM
Macro needed to Paste Values and prevent Macro operation thunderfoot Excel Discussion (Misc queries) 0 June 10th 05 03:38 PM


All times are GMT +1. The time now is 10:41 PM.

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"