Hi everyone. I hope you can give me some high-level guidance on something I'm working on. I'm beginning to learn VBA for Excel and have a specific problem I wish to solve (/ dynamic workbook I want to make) in mind. Part of the workbook will involve taking a list of stock tickers, their associated name, sector, and subsector and putting it in a list somewhere else. For example three lines of data are
AMZN Amazon.com, Inc. Consumer Discretionary Internet & Catalog Retail KO Coca-Cola Company Consumer Staples Beverages XOM Exxon Mobil Corporation Energy Oil Gas & Consumable Fuels
There are more than 500 rows like that ^ and they change every once in a while. The first two columns never repeat, while the third and fourth (sector and subsector) repeat often.
I would like to make lists, for example, of everything in Consumer Discretionary. And separately, everything in Beverages. And separately, everything in Oil Gas & Consumable Fuels. My question is what is the best way to implement this?
I've been reading a lot about potential different ways to do this and don't know which will make my life hardest/toughest. Considering the data (e.g. the values in each row will always be associated with each other), should I use...
- A 2D array?
- A collection?
- A dictionary?
- A 1D array with a user-defined type that includes four strings?
- Something else?
I can upload a workbook if you want, but I'm not expecting too much code, if any, in an answer. Let me know if you need more information. Thanks
EDIT: I should clarify that the length and members of all the lists are variable. (Depends on the original list from which everything else is derived...)
Bookmarks