I decided to start this question from scratch to clarify the question and goal.
Things to note about my data
- I have a spreadsheet containing laptop product data
- Each product has a Model and a SKU value
- Many models have multiple SKUs associated with them
- When more than 1 SKU fits into a model, there is a new row for each SKU. In this instance, each row will have the same value in the model field
- Some models may have 4 batteries & 1 charger, others may have 1 battery & 2 chargers, others may have 1 battery & no charger or vice versa... what i'm trying to say is there is no set rule or relation between number of SKUs
- There are two types of products, batteries & chargers
- All Battery products have SKUs that begin with 'BAT'
- All charger products have SKUS that begin with either 'ACA' or 'ACS'
- I can easily split the two types of data to help achieve the goal - SKU, model & category data can be placed side by side in columns or in separate worksheets for each type of product (battery or charger)
Example data formatted side by side in same worksheet:
Example data in separate worksheets (sheet1 = batteries, sheet2 = chargers):
Regardless of which method is used, the model field could be positioned anywhere in column A - the model field will not be in an adjacent cell when comparing the two sets of data (as illustrated)
What I am trying to achieve
- For each model, I need to have a row of data containing a battery SKU and a charger SKU
- There should be a new row for the same model until all combinations are output for that model
- There should be a maximum of 2 SKUs in the output for each row. This should always contain 1 battery and 1 charger
Desired Output
It is worth mentioning that this is a very small sample of the data I will be working with, full data set is more than 60k rows and growing so the solution would need to be efficient.
I'm using excel 2007.
I am a complete noob with VBA, I have purchased some plug ins to try and achieve my goal, I have spent 2 days researching and trying various methods to do this but all to no avail.
I thought that I had got close with this answer from Santosh:
https://stackoverflow.com/a/19780188/1018153
Which is what I based my previous question on, but as well as that producing duplicates and matching data between models, I couldn't actually format my data in it's complete form for that script to work for me anyway, so my original question was irrelevant.