Transpose cells separated with "," and duplicate data in rows

SVDCF

New Member
Joined
Jul 20, 2016
Messages
7
Hello everyone!

I am new to this forum and I would like to raise a question regarding the thread :
http://www.mrexcel.com/forum/excel-...utomatically-insert-new-rows.html#post4521996

I would like to do this same operation but the column I want to replicate is in column "HT".

How can I change this macro do to the transpose in column "HT"?

Additionally, why I am always getting the following error "Mismatch" highlighting the "Sheets("sheet1").Range("a1").Resize(c, UBound(Ray, 2)) = Application.Transpose(nray)".

I have no idea how to correct it.

Appreciated!

K.Regards
Sara


Sub som()
Dim Ray As Variant, n As Long, Sp As Variant, c As Long, s As Long, Ac As Long
Ray = ActiveSheet.Range("A1").CurrentRegion
ReDim nray(1 To UBound(Ray, 2), 1 To 1)


For n = 1 To UBound(Ray, 1)
Sp = Split(Ray(n, 2), ",")
For s = 0 To UBound(Sp)
c = c + 1
ReDim Preserve nray(1 To UBound(Ray, 2), 1 To c)
For Ac = 1 To UBound(Ray, 2)
If Ac = 2 Then
nray(Ac, c) = Sp(s)
Else
nray(Ac, c) = Ray(n, Ac)
End If
Next Ac
Next s
Next n
Sheets("sheet1").Range("a1").Resize(c, UBound(Ray, 2)) = Application.Transpose(nray)
MsgBox "Run"
End Sub
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
You could try:-
Sp = Split(Ray(n, 228), ",")

228 being column "Ht"
Please post Data example if this does not work
 
Upvote 0
You could try:-
Sp = Split(Ray(n, 228), ",")

228 being column "Ht"
Please post Data example if this does not work

Hi MickG!

Thank you for that! I was wondering where the cell value would go.

I just have a minor problem now, the mismatch error : run time error 13

"Sheets("sheet1").Range("a1").Resize(c, UBound(Ray, 2)) = Application.Transpose(nray)"

am I using wrong names for the sheets? what names should i use for the source sheet and the result sheet?
 
Upvote 0
hello Sheetspread!
There is one little thing i need extra, the data should be copied in the duplicated rows.

I am going to check the video you sent

Thank you!
Sara
 
Upvote 0
the data should be copied in the duplicated rows.

The macro does this, but has to be changed slightly if your column containing delimited values is 228 instead of 1. Also tell me on which row the data begins if not row 2.

Since you have multiple labeling columns, the method described in the video would require that they be concatenated first.
 
Last edited:
Upvote 0
The Data sheet is the Active sheet .
The results sheet is shown as sheet1, but you can change it as required.
 
Upvote 0
The macro does this, but has to be changed slightly if your column containing delimited values is 228 instead of 1. Also tell me on which row the data begins if not row 2.

Since you have multiple labeling columns, the method described in the video would require that they be concatenated first.


Yes! the column with the values in number 228 and the data starts on row 2
 
Upvote 0
Without knowing where your columns start, I tried this and it worked:

Excel 2010
HTHUHVHWHX
1Cust partOur partsOur IDCurrencyPrice
2135649A1, A75262Part AD1E+08USD$18.95
3138642, BN98510, 190585R91Part O1E+08USD$7.82
4163044, BN98509Part W1E+08USD$4.57
5179080, BSET2Part U1E+08USD$3.97
618427, ST791Part P1E+08USD$7.82
721076D, E3NN3123AA, 210760Part N1E+08USD$3.66
844401, 694735 CONE, ST775APart C1E+08USD$6.44
9459456R91, 86576982 - CONE, 273423Part L1E+08USD$3.83
1047508360, 52443, 664175R92Part F1E+08USD$13.22
Sheet3 (3)

Code:
Sub parsetranspose()
Dim x%, y%, partarray As Variant
x = 2
Do Until Cells(x, 228).Value = ""
y = Len(Cells(x, 228)) - Len(Replace(Cells(x, 228).Value, ",", ""))
If y > 0 Then
ReDim partarray(y)
partarray = Split(Cells(x, 228).Value, ",")
Rows(x + 1).Resize(y).Insert
Range("HT" & x).Resize(y + 1).Value = Application.Transpose(partarray)
Range("HU" & x & ":HX" & x).Resize(y + 1).Value = Range("HU" & x & ":HX" & x).Value
Else
End If
x = x + y + 1
Loop
End Sub

Excel 2010
HTHUHVHWHX
1Cust partOur partsOur IDCurrencyPrice
2135649A1Part AD100110399USD$18.95
3A75262Part AD100110399USD$18.95
4138642Part O100027144USD$7.82
5BN98510Part O100027144USD$7.82
6190585R91Part O100027144USD$7.82
7163044Part W100026523USD$4.57
8BN98509Part W100026523USD$4.57
9179080Part U100045902USD$3.97
10BSET2Part U100045902USD$3.97
1118427Part P100047915USD$7.82
12ST791Part P100047915USD$7.82
1321076DPart N100050683USD$3.66
14E3NN3123AAPart N100050683USD$3.66
15210760Part N100050683USD$3.66
1644401Part C100055719USD$6.44
17694735 CONEPart C100055719USD$6.44
18ST775APart C100055719USD$6.44
19459456R91Part L100096658USD$3.83
2086576982 - CONEPart L100096658USD$3.83
21273423Part L100096658USD$3.83
2247508360Part F100081326USD$13.22
2352443Part F100081326USD$13.22
24664175R92Part F100081326USD$13.22
Sheet3 (3)
 
Last edited by a moderator:
Upvote 0

Forum statistics

Threads
1,221,537
Messages
6,160,401
Members
451,645
Latest member
hglymph

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