tracyms
asked on
Filter Excel data and send in email body
I have a spreadsheet with combo boxes that filters data. Once this data is filtered, I'd like only that filtered data sent to the body of an email message. I want to be prompted for an email address so I can send to who I need to.
I've attached an example that I found by using google (see the "send row' tab in the spreadsheet) that does close to what I need except that:
- it uses outlook, I have groupwise client
- I want to input the email address (be prompted to enter an email address or simply open the email client with data embedded and I can enter the email address)
- Send the filtered data only (data shown once I filter the data)
Thanks in advance for your assistance.
Outlook-Body-Testers.xls
I've attached an example that I found by using google (see the "send row' tab in the spreadsheet) that does close to what I need except that:
- it uses outlook, I have groupwise client
- I want to input the email address (be prompted to enter an email address or simply open the email client with data embedded and I can enter the email address)
- Send the filtered data only (data shown once I filter the data)
Thanks in advance for your assistance.
Outlook-Body-Testers.xls
ASKER
Your code works when I try at home but I have outloook at home. I will try it when I go to work where I use groupwise and post back.
I was able to add your code to my combo box filter and it highlighted/activated the filtered data which is great - see below:
************************** *********
Sub DropDown7_Change()
Dim myValue As String
Dim myDrop As DropDown
Set myDrop = Sheets("Fall 2012 ").DropDowns("Drop Down 7")
With myDrop
If .ListIndex = 1 Then
MsgBox "Nothing was selected"
Else
ActiveSheet.Range("A7:S98" ).Select
ddValue = .List(.ListIndex)
ActiveSheet.Range("A7").Au toFilter Field:=1, Criteria1:=ddValue
' Show the envelope on the ActiveWorkbook.
ActiveWorkbook.EnvelopeVis ible = True
With ActiveSheet.MailEnvelope
.Introduction = "This is a sample worksheet."
.Item.To = "E-Mail_Address_Here"
.Item.Subject = "My subject"
End With
End If
End With
End Sub
************************** *********
I also have a text seach on my spreadsheet that I'd like to do the same way but not sure where to put your code, below is the current code for the text search filter:
************************** *********
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Range("D1"), Target) Is Nothing Then
If Target = "" Then
ActiveSheet.Range("$A$7:$W $100").Aut oFilter Field:=1
Else
ActiveSheet.Range("$A$7:$W $100").Aut oFilter Field:=1, Criteria1:="*" & Target & "*"
End If
End If
************************** *********
Finally, is there a way to hide the email until needed. It stays in the spreadsheet until I close the spreadsheet. Maybe show/hide button or button that says "send email" and closes/hides email program when email is sent?
Thanks again!
I was able to add your code to my combo box filter and it highlighted/activated the filtered data which is great - see below:
**************************
Sub DropDown7_Change()
Dim myValue As String
Dim myDrop As DropDown
Set myDrop = Sheets("Fall 2012 ").DropDowns("Drop Down 7")
With myDrop
If .ListIndex = 1 Then
MsgBox "Nothing was selected"
Else
ActiveSheet.Range("A7:S98"
ddValue = .List(.ListIndex)
ActiveSheet.Range("A7").Au
' Show the envelope on the ActiveWorkbook.
ActiveWorkbook.EnvelopeVis
With ActiveSheet.MailEnvelope
.Introduction = "This is a sample worksheet."
.Item.To = "E-Mail_Address_Here"
.Item.Subject = "My subject"
End With
End If
End With
End Sub
**************************
I also have a text seach on my spreadsheet that I'd like to do the same way but not sure where to put your code, below is the current code for the text search filter:
**************************
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Range("D1"), Target) Is Nothing Then
If Target = "" Then
ActiveSheet.Range("$A$7:$W
Else
ActiveSheet.Range("$A$7:$W
End If
End If
**************************
Finally, is there a way to hide the email until needed. It stays in the spreadsheet until I close the spreadsheet. Maybe show/hide button or button that says "send email" and closes/hides email program when email is sent?
Thanks again!
Sub DropDown7_Change()
Dim myValue As String
Dim myDrop As DropDown
Set myDrop = Sheets("Fall 2012 ").DropDowns("Drop Down 7")
With myDrop
If .ListIndex = 1 Then
MsgBox "Nothing was selected"
Else
ActiveSheet.Range("A7:S98").Select
ddValue = .List(.ListIndex)
ActiveSheet.Range("A7").AutoFilter Field:=1, Criteria1:=ddValue
' Show the envelope on the ActiveWorkbook.
ActiveWorkbook.EnvelopeVisible = True
With ActiveSheet.MailEnvelope
.Introduction = "This is a sample worksheet."
.Item.To = "E-Mail_Address_Here"
.Item.Subject = "My subject"
End With
End If
End With
End Sub
ASKER
I have this on a command button but would like to merge with another drop down since I have 2 ciriteras for searching (columns 1 and 3). This current one is working but when add the other it doesn't:
Private Sub CommandButton1_Click()
Dim myValue As String
Dim myDrop As DropDown
Set myDrop = Sheets("Fall 2012 ").DropDowns("Drop Down 7")
With myDrop
If .ListIndex = 1 Then
MsgBox "Nothing was selected"
Else
ActiveSheet.Range("A7:S98" ).Select
ddValue = .List(.ListIndex)
ActiveSheet.Range("A7").Au toFilter Field:=1, Criteria1:=ddValue
' Show the envelope on the ActiveWorkbook.
ActiveWorkbook.EnvelopeVis ible = True
With ActiveSheet.MailEnvelope
.Introduction = "This is a sample worksheet."
.Item.To = "E-Mail_Address_Here"
.Item.Subject = "My subject"
End With
End If
End With
End Sub
This is the other:
Set myDrop = Sheets("Fall 2012 ").DropDowns("Drop Down 12")
With myDrop
If .ListIndex = 1 Then
MsgBox "Nothing was selected"
Else
ActiveSheet.Range("A7:S98" ).Select
ddValue = .List(.ListIndex)
ActiveSheet.Range("A7").Au toFilter Field:=3, Criteria1:=ddValue
' Show the envelope on the ActiveWorkbook.
ActiveWorkbook.EnvelopeVis ible = True
With ActiveSheet.MailEnvelope
.Introduction = "This is a sample worksheet."
.Item.To = "E-Mail_Address_Here"
.Item.Subject = "My subject"
End With
End If
End With
Private Sub CommandButton1_Click()
Dim myValue As String
Dim myDrop As DropDown
Set myDrop = Sheets("Fall 2012 ").DropDowns("Drop Down 7")
With myDrop
If .ListIndex = 1 Then
MsgBox "Nothing was selected"
Else
ActiveSheet.Range("A7:S98"
ddValue = .List(.ListIndex)
ActiveSheet.Range("A7").Au
' Show the envelope on the ActiveWorkbook.
ActiveWorkbook.EnvelopeVis
With ActiveSheet.MailEnvelope
.Introduction = "This is a sample worksheet."
.Item.To = "E-Mail_Address_Here"
.Item.Subject = "My subject"
End With
End If
End With
End Sub
This is the other:
Set myDrop = Sheets("Fall 2012 ").DropDowns("Drop Down 12")
With myDrop
If .ListIndex = 1 Then
MsgBox "Nothing was selected"
Else
ActiveSheet.Range("A7:S98"
ddValue = .List(.ListIndex)
ActiveSheet.Range("A7").Au
' Show the envelope on the ActiveWorkbook.
ActiveWorkbook.EnvelopeVis
With ActiveSheet.MailEnvelope
.Introduction = "This is a sample worksheet."
.Item.To = "E-Mail_Address_Here"
.Item.Subject = "My subject"
End With
End If
End With
Did you manage to test this on your non-outlook mail system?
I can see that there is other work to do here, but I would like to be sure that we have a suitable mail method before looking at other code lines.
(as the whole thing may need to be re-written as the mail method changes).
I can see that there is other work to do here, but I would like to be sure that we have a suitable mail method before looking at other code lines.
(as the whole thing may need to be re-written as the mail method changes).
ASKER
No, it didn't work. There is an "email as pdf attachment" in excel. I tried that but it sends the entire workbook and not just the filtered data. My thought is if I can send the filtered data to a new workbook and email from there it should work. Perhaps have a button on the spreadsheet that says "Email Results" and it'll send filtered range to new workbook and attach to the email and delete the workbook. Suggestions welcome. Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
waiting for the solution!
but to get started, does this work with your mail program? :)
Open in new window