Try this workbook.
The simplest way to get your result is to use SUBTOTAL in Sheet2 then filter by "Style Code" then by column "Size Code"
This is also versitile
You can then SUM by styles, or sizes, or any combination that might interest you.
In E1
If you must split the "Style Code" into unique Code and Size, then it might be tricky to get a formula for Column "Style Code".
At this stage let's assume you have generated Column A manually
In B2
In C2
Drag/Fill both Down.
Hope this helps
[EDIT]
Here is one way to generate a unique list of "Style ID" and "Sizes" (see "Sheet3")
First sort your data by "Style Code" then by column "Size Code"
Use two Helper Columns A & B. (these can be hidden with the grouping button +/-)
In A2
Drag/Fill Down until the formula returns a null string i.e. ""
In B2
Drag/Fill Down until the formula returns a null string i.e. ""
In C2 This will generate the code and put it in the correct number of rows ot match the number of sizes.
Drag/Fill Down
Columns D & E are the original formulae re-referenced and nested in an if statement to ignore blank rows.
I have updated the attachment.
Bookmarks