Interesting and complicated problem, need vba help on processing multiple columns of data into rows

spyrule

Board Regular
Joined
Aug 21, 2015
Messages
114
hello,
I've got an interesting problem to solve. I've got a worksheet that will be re-used repeatedly to take raw automotive data and "convert" that data into a specifically formatted text output on another sheet.

Here is a sample source table of the data I have to process:
Source Sheet:​
SKUYEARMAKEMODELSUB-MODEL
ProductA2006-2013|2005-2009Audi|VolkswagenA3|GTI
ProductB2002-2007;2008|2006-2010Subaru|MitsubishiImpreza;Legacy|Lancer2.5i,WRX,STi;GT,SpecB|GS

<tbody>
</tbody>


Here is what the output should be like:
Destination Sheet:​
SKUYEARMAKEModelSub-Model
ProductA2006-2013AudiA3
ProductA2005-2009VolkswagenGTI
ProductB2002-2007SubaruImpreza2.5i
ProductB2002-2007SubaruImprezaWRX
ProductB2002-2007SubaruImprezaSTi
ProductB2008SubaruLegacyGT
ProductB2008SubaruLegacySpecB
ProductB2006-2010MitsubishiLancerGS

<tbody>
</tbody>

So as you can see, this is a lot of text processing with several different rules.

1) The sheet can have anywhere from 1 to 100,000 rows of data like this. The columns themselves WILL NOT be in this order, but will be spread out, and will have Named Ranges applied to each column for easy "grabbing" of that chunk of data.
2) The Pipe symbol will always designate a major separation of Year/Makes/Model/Sub-Models (YMMS). Meaning if a pipe symbol is encountered, it should be expected to find a matching pipe symbol in the rest of the YMMS columns.
3) semi-colons are used as symbol to split data within the same piped sequence.
4) commas are used to indicate that each piece of data between the commas will require a new line of data.
5) If there is commas and/or semi-colons encountered and there is no matching option in the next column over, leave the value blank, and start the next destination row.
6) If there is NO comma and/or semi-colons specified in the previous column, then re-use the same value within the same pipe segment.
7) I'm sure I'm missing a rule atm (its 1AM and I'm wiped).

I'd love to hear from people on what they think might be the best/most efficient way to handle this problem, hopefully with some sample code ideas.

Thanks in advance,

Spyrule.
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
So the first one really isn't relevant to this problem, it is more about chunking alt-enter values in a single cell into multiple row (which I guess could be modified to use comma seperated values).
The second link, however does seem to reference some of what I need, except that it only supports a single column of data. I might have to approach it with a bunch of arrays, or possibly a 3+ dimensional array (which I dont really know how to do, and will have to research it).
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,461
Messages
6,124,952
Members
449,198
Latest member
MhammadishaqKhan

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top