another transpose problem

SeanDamnit

Board Regular
Joined
Mar 13, 2011
Messages
151
Hello Collective Conciousnes of Mr. Excel.

I have data that looks like this:

Excel Workbook
ABCDEF
1Product SKURMA?DescriptionQuantityVendor SKUBar Code
39ACCAHT000354NoHard Shell Case Gray EVO1376580888063765803
40ACCAHT000651NoHTC EVO SHIFT HARD SHELL BLUE/BLACK570H00370-04M, 821793011307
41ACCAHT000652NoHTC EVO SHIFT HARD SHELL PINK/WHITE535958370H00370-06M, 821793011321, 888063595837
42ACCALG000269NoBODY GLOVE LG5108375231043859614332, 888063752315, 9143301, BGCOVRUMTOUCH
43ACCAMO000366NoCarry Holster, i5802393278781420011561, 888063932786
44ACCANL000316NoNLU 15 Pack of Fitted Screen Protectors1304702878966000644, 888063047022
45ACCAOT000368NoDefender Case, 83001352808660543002314, 888063528088
Sheet1




Note the highlighted Bar Code column

I would like for it to look like this:

Excel Workbook
ABCDEF
1Product SKURMA?DescriptionQuantityVendor SKUBar Code
2ACCAHT000354NoHard Shell Case Gray EVO1376580888063765803
3ACCAHT000651NoHTC *EVO SHIFT HARD SHELL BLUE/BLACK5*70H00370-04M
4ACCAHT000651NoHTC *EVO SHIFT HARD SHELL BLUE/BLACK5*821793011307
5ACCAHT000652NoHTC EVO SHIFT HARD SHELL PINK/WHITE535958370H00370-06M
6ACCAHT000652NoHTC EVO SHIFT HARD SHELL PINK/WHITE5359583821793011321
7ACCAHT000652NoHTC EVO SHIFT HARD SHELL PINK/WHITE5359583888063595837
8ACCALG000269NoBODY GLOVE LG510837523143859614332
9ACCALG000269NoBODY GLOVE LG5108375231888063752315
10ACCALG000269NoBODY GLOVE LG51083752319143301
11ACCALG000269NoBODY GLOVE LG5108375231BGCOVRUMTOUCH
12ACCAMO000366NoCarry Holster, i5802393278781420011561
13ACCAMO000366NoCarry Holster, i5802393278888063932786
14ACCANL000316NoNLU 15 Pack of Fitted Screen Protectors1304702878966000644
15ACCANL000316NoNLU 15 Pack of Fitted Screen Protectors1304702888063047022
16ACCAOT000368NoDefender Case, 83001352808660543002314
17ACCAOT000368NoDefender Case, 83001352808888063528088
Sheet2


In other words, for every Bar Code separated by a comma, I'd like to create a new row with duplicate information. I have much more data than the sample set here, and the bar code column can have any number of unique entries, so any solution there is will have to account for that.

I'm doing my best to learn VBA - and seeing how the pros handle this will definitely boost my knowledge.

I appreciate it!
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Try this :-
Results start "G1".
Code:
[COLOR="Navy"]Sub[/COLOR] MG15Sep50
[COLOR="Navy"]Dim[/COLOR] Rng [COLOR="Navy"]As[/COLOR] Range, Dn [COLOR="Navy"]As[/COLOR] Range
[COLOR="Navy"]Dim[/COLOR] c [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
[COLOR="Navy"]Dim[/COLOR] Ac [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Integer[/COLOR]
[COLOR="Navy"]Dim[/COLOR] n [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Integer[/COLOR]
[COLOR="Navy"]Dim[/COLOR] Bcode [COLOR="Navy"]As[/COLOR] Variant
[COLOR="Navy"]Set[/COLOR] Rng = Range(Range("A2"), Range("A" & Rows.Count).End(xlUp))
    ReDim ray(1 To Rng.Count * 4, 1 To 6)
    [COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn [COLOR="Navy"]In[/COLOR] Rng
        Bcode = Split(Dn(, 6), ",")
        [COLOR="Navy"]For[/COLOR] n = 0 To UBound(Bcode)
            c = c + 1
            [COLOR="Navy"]For[/COLOR] Ac = 1 To 5
                ray(c, Ac) = Dn(, Ac)
            [COLOR="Navy"]Next[/COLOR] Ac
                ray(c, 6) = Format(Bcode(n), "0")
        [COLOR="Navy"]Next[/COLOR] n
    [COLOR="Navy"]Next[/COLOR] Dn
Columns("L:L").NumberFormat = "0"
Range("G1").Resize(c, 6) = ray
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0
Try this :-
Results start "G1".
Code:
[COLOR="Navy"]Sub[/COLOR] MG15Sep50
[COLOR="Navy"]Dim[/COLOR] Rng [COLOR="Navy"]As[/COLOR] Range, Dn [COLOR="Navy"]As[/COLOR] Range
[COLOR="Navy"]Dim[/COLOR] c [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
[COLOR="Navy"]Dim[/COLOR] Ac [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Integer[/COLOR]
[COLOR="Navy"]Dim[/COLOR] n [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Integer[/COLOR]
[COLOR="Navy"]Dim[/COLOR] Bcode [COLOR="Navy"]As[/COLOR] Variant
[COLOR="Navy"]Set[/COLOR] Rng = Range(Range("A2"), Range("A" & Rows.Count).End(xlUp))
    ReDim ray(1 To Rng.Count * 4, 1 To 6)
    [COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn [COLOR="Navy"]In[/COLOR] Rng
        Bcode = Split(Dn(, 6), ",")
        [COLOR="Navy"]For[/COLOR] n = 0 To UBound(Bcode)
            c = c + 1
            [COLOR="Navy"]For[/COLOR] Ac = 1 To 5
                ray(c, Ac) = Dn(, Ac)
            [COLOR="Navy"]Next[/COLOR] Ac
                ray(c, 6) = Format(Bcode(n), "0")
        [COLOR="Navy"]Next[/COLOR] n
    [COLOR="Navy"]Next[/COLOR] Dn
Columns("L:L").NumberFormat = "0"
Range("G1").Resize(c, 6) = ray
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick

Works perfect, MickG. I appreciate the help - you have no idea how much time this saves me.
 
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,762
Members
452,940
Latest member
rootytrip

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