VBA to Filter Multiple Sheets and Email File

mamclero

New Member
Joined
Oct 31, 2017
Messages
5
Hello,

I'm hoping someone could help me out with a file I have at work that is taking lots of time. We get a report with multiple division's information on it, and we have to filter down for each division on each tab (removing the other divisions), and then email out the files to that respective division.

I've been digging around on the board, and I know it's possible to do what I'm trying to do via VBA, I'm just a little lost at where to begin.

Overview:

There are three data tabs in the file, Summary1, Proposal1, and Mgmt1. I get all of the data in these files and have to filter down to each division and delete the other division's information. Once I do that, I have to refresh a pivot table, save the file, and then email the file as an attachment to a pre-defined group.

Detail:

The file starts with a "Summary1" tab, and the division starts in cell A4, going down. There is a second tab in the workbook with the same division in cell D4, going down (sheet name is "Proposal1"). On the Proposal1 tab, there are a series of companies listed in column E. In order to filter the last tab, "Mgmt1", you need to lookup the remaining values in column E in the Proposal tab after you've filtered, and delete the "N/A's" (companies to lookup are in column A for the "Mgmt1" tab). The data is arranged on the Mgmt tab so you could do a vlookup in column I and then delete it after the lookup and filter has occurred.

Lastly, there is pivot table on the tab "Pivot", the Pivot table name is just "Pivottable1". This needs to be refreshed after the filters have occurred.

Once the data has been filtered, the file needs to be saved to a location, we'll use "C:/Sample/" for this example, with the division's name on it. The file then needs to be attached to an email and sent to the division (really just need to use the display versus send functionality so I can review the files before sending).

On the spreadsheet, I've created a tab named "Email_Details", and put the division names in column A, the "To" recipients in column B, the subject in column C, and the body in column D. If a division occurs in the Summary1, Proposal1 or Mgmt1 tabs that isn't on the email tab, I'd like an error message to pop up telling me to insert the data before resuming. If one of the divisions isn't on the first three tabs, but is in my email tab, that can be ignored. I'd also need to hide the "Email_Details" tab, or better yet delete it.

I'd like the code to loop through each division, filter down the results (and delete the others), save the file and create the email.

Thanks so much in advance and sorry for the long post! I'm happy to share a file if easier to look at the information that way or if something isn't clear.
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

Forum statistics

Threads
1,223,894
Messages
6,175,254
Members
452,623
Latest member
Techenthusiast

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