PDA

View Full Version : Excel VBA and arrays



collector00
07-12-2022, 11:40 AM
Hi All, I'm in a situation that I cannot figure out the best way to handle without creating a bunch of IF THEN and FOR statements. The issue I have is like peeling back the skin of an onion and continues to get bigger and bigger.

Let me try to explain. I have an excel spreadsheet that isn't very large but there are two columns in the spreadsheet that contain mutliple values. What I need is a list of those values but as separate rows in the spreadsheet, not clustered together. One column is names of groups and the other email addresses. The groups are separated by commas and the emails by semi-colons. I created a quick script that goes through each row and extracts the groups then creates a new list (so some of the data from the original file) but under group name, it only lists the one; and repeats this for every group. When all groups have been listed it goes onto the next row and does the same. It seemed to work okay but then was getting bloated when I started adding the email address work.

What I would like is a script that goes through each row in the original file. Copies some of the details to a new tab (like ID). Then if it finds data in the group or email address column, adds each of those as a separate row (with the corresponding ID field). On top of all of this, the groups are associated to email addresses as well, if I could have one script that also looks at those and creates separate rows for them that would be great.

I'm trying to create a repeatable VBA script so I don't have to do this manually each time.

I know this is a lot and would appreciate any guidance whatsoever.

snb
07-12-2022, 11:48 AM
I can copy my macro into your file.