Attach an excel file automatically to email with VBA

audrey

Active Member
Joined
Jul 30, 2008
Messages
491
Hello,

i was wondering if the following can be simplified using VBA ?

Action
I have two tabs in my excel spreadsheet. Tab1 and Tab2.
In Tab2, Cell A1, I type "USA"

VBA
The VBA should then filter only "USA" in Column C in Tab1
Remove the other rows in Tab1 which is not "USA"
Attach the Tab1 to Outlook as "xlsx"
with an email body text "Please see attached"
While doing it, I also do not want to lose the data in Tab1 ?


Thank you very much already!
Aude
 
Yes that should work as long as it resets the data to remove the filter which my code does do, but the condition must exist.

As to the formatting of the Body try this.

.htmlBody = "!BODY style=font-size:11pt;font-family:Calibri?Good Morning; !p?!p?Paragraph 1!/p?!p?Paragraph 2!/p?"

Again change each ! to a <
And change each ? to a >

As far as the signature goes you would need to know where the signature is being stored within your PC (Not just in outlook), so perhaps use the paragraph breaks and add something into the email.
 
Upvote 0

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
thanks again, I resolved the other issues, but this one still remains


hi, when I press the <acronym title="visual basic for applications">VBA</acronym> button twice. I also get a debug error

Selection.Offset(1, 0).Resize(Selection.Rows.Count - 1).Copy
 
Upvote 0

Forum statistics

Threads
1,215,465
Messages
6,124,977
Members
449,200
Latest member
Jamil ahmed

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top