Hi Mat,
What about something like
Code:
dim cel as range
for each cel in wks_Company_Names.Range("Companies")
'do whatever with cel.value, the company name
next cel
Or in an array, loop through from the LBound to the UBound.
The hurdle is setting up the list of unique names. Excel has built-in functionality do that - the advanced filter.
Another way is a data table query on the "Company" field. Such as to a separate worksheet and give the result a defined name. Each time the query is refreshed the named range will automatically adjust. Just be aware that the header will be included in the named range, so, exclude it if looping like posted above. The query would have SQL of the form "SELECT DISTINCT Company FROM table_whatever" and could be set up once outside VBA and then VBA would simply "wks_Whatever.QueryTables(1).Refresh BackgroundQuery:=False", or, otherwise create the query on the fly each time. I've found if doing this second way, better to create a new worksheet each time and delete it after use.
Thinking further, if you don't want to create a unique list, build one as you go. Such as start with the company name in the first record, store it in an array "UsedNames", do the processing, LOOP STARTS, go to the company name in the next record, check if it is in array "UsedNames", if not add name to the list, do the processing, LOOP
OK?
Fazza