PC Review


Reply
Thread Tools Rate Thread

Auto send spreadsheets as email attachments

 
 
=?Utf-8?B?SkRheXdhbHQ=?=
Guest
Posts: n/a
 
      7th Aug 2007
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 With Quote
 
 
 
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      7th Aug 2007
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 With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Auto Print email and word attachments on send Matt Bennette Microsoft Outlook VBA Programming 3 14th Apr 2009 06:54 PM
Outlook 2003 does not auto poll/auto send/receive email jodie.berger1@gmail.com Microsoft Outlook Discussion 2 13th Mar 2008 07:14 PM
I can't send attachments with outlook, I can send test email =?Utf-8?B?SGFybSBMb2dhbg==?= Microsoft Outlook 5 21st Mar 2007 06:51 PM
Using SendObject to send email, want to send attachments Darhl Thomason Microsoft Access Form Coding 1 3rd Feb 2006 07:27 PM
How do I send Word attachments in email mesages that auto open =?Utf-8?B?S2lyaw==?= Microsoft Outlook Discussion 1 9th Jun 2004 05:23 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:20 PM.