Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Auto send spreadsheets as email attachments

I have a list of names in cells A1:A10 on a sheet tab called 'Names'. On
another sheet tab called 'Data', I have a range of data with an autofilter,
where column A includes these names, and columns B thru Z contains other
data. What I'd like to do is write code that will take each name on the
list, filter the data for that name, then automatically send the filtered
data as an email attachment to that person. It would then cycle through
until the whole list is completed. Can this be done?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Auto send spreadsheets as email attachments

sub ProcessData()
Dim cell as Range, bk as Workbook
Dim rng as Range, bNewSheet as Boolean
for each cell in worksheets("Names").Range("A1:A10")
if not bNewSheet then
set bk = Workbook.Add(Template:=xlWBATWorksheet)
bNewSheet = True
end if
With worksheets("Data")
bk.worksheets(1).Cells.Clear
set rng = .Autofilter.Range
.Autofilter Field:=1, Criteria1:=cell.Value
rng.copy bk.Worksheets(1).Range("A1")
bk.Sendmail Recipients:=cell.Value, Subject:="Your Data"
End With
Next
bk.Close Savechanges:=False
End Sub

You might have to mess with this:

Recipients:=cell.Value

to make sure it is a valid email address. maybe put the email address in
column B of names then

Recipients:=cell.Offset(0,1).Value

The above code is untested and may contain typos or require tweaking.

--
regards,
Tom Ogilvy


"JDaywalt" wrote:

I have a list of names in cells A1:A10 on a sheet tab called 'Names'. On
another sheet tab called 'Data', I have a range of data with an autofilter,
where column A includes these names, and columns B thru Z contains other
data. What I'd like to do is write code that will take each name on the
list, filter the data for that name, then automatically send the filtered
data as an email attachment to that person. It would then cycle through
until the whole list is completed. Can this be done?

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
Help! Macro to send email from Excel and add other attachments Rafael_SP Excel Programming 3 February 21st 07 01:55 PM
Send an email, some with/without attachments [email protected] Excel Discussion (Misc queries) 0 January 22nd 07 08:34 PM
Auto Send email from IF command Stuiart Excel Worksheet Functions 0 November 13th 06 02:11 AM
Can Excel auto-send an email on a given date? dannykray_z Excel Discussion (Misc queries) 1 April 18th 06 07:43 PM
how can i send email with attachments paths (3 workbooks) located in the cell a1 to a3 VB Script for Excel Excel Programming 1 March 26th 06 02:44 PM


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