Solved

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

Posted on 2013-05-16
4
293 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
Comment Utility
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
Comment Utility
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
In this article we discuss how to recover the missing Outlook 2011 for Mac data like Emails and Contacts manually.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

762 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

8 Experts available now in Live!

Get 1:1 Help Now