Solved

Loop through each filter value and add matching row values to an array

Posted on 2013-05-16
4
295 Views
Last Modified: 2014-05-23
Hi Everyone,

I have a spreadsheet that has 2 columns (with headers). The columns are Branch and DisplayName. Right now there are about 700 total rows in my spreadsheet. What I'm trying to accomplish here is to create Outlook e-mails populated with display names in to the TO field based on each distinct Branch value. There are about 15 different branch values when you look at the filter dropdown in excel. In this case, the VBA would generate 15 different e-mails with the display names of each person in their respective branch populated in the TO field.

I have the VBA code to create and populate e-mails created. I just have no clue how to loop through each distinct value of the filter and retrieve the respective matching rows for each distinct value.

Thanks for your help!
0
Comment
Question by:26fconsulting
4 Comments
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 500 total points
ID: 39171712
As far as I know, there is no direct way to access the filter items.

What I would do is use a "Dictionary of Dictionaries" to find the unique items.  The "parent" Dictionary would have a key for each branch, and the item would be child Dictionary containing the unique display names for that branch.

When generating the emails, , loop through the parent Dictionary to generate the emails, and then use the keys from the child Dictionary to populate the "To" field.

If you need more help than this, a sample file would be useful.
0
 
LVL 19

Expert Comment

by:akoster
ID: 39222450
elsewise you could implement a pivot table to get the distinct branch values and use the rows of the pivot table to generate the emails, then use columns of the pivot table (the displaynames) to populate each email.

An educated guess would be that following matthewspatrick's advise will be the better approach for you though.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article we discuss how to recover the missing Outlook 2011 for Mac data like Emails and Contacts manually.
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

27 Experts available now in Live!

Get 1:1 Help Now