Hi,
in filed I have couple of value separated by comma like below:
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]A1 header1
[/TD]
[TD]B1 header2
[/TD]
[TD]C1 header3
[/TD]
[/TR]
[TR]
[TD]Audi
[/TD]
[TD]592035, 579733, 653749, 579735
[/TD]
[TD]20 000
[/TD]
[/TR]
</tbody>[/TABLE]
If my macro found that string (always will be separate by ",") should split the string and add rows (= to number of string). The output should be as below:
[TABLE="class: grid, width: 300"]
<tbody>[TR]
[TD]A1 header1
[/TD]
[TD]B1 header2
[/TD]
[TD]C1 header3
[/TD]
[/TR]
[TR]
[TD]Audi
[/TD]
[TD]592035
[/TD]
[TD]20 000
[/TD]
[/TR]
[TR]
[TD]Audi
[/TD]
[TD]579733
[/TD]
[TD]20 000
[/TD]
[/TR]
[TR]
[TD]Audi
[/TD]
[TD]653749
[/TD]
[TD]20 000
[/TD]
[/TR]
[TR]
[TD]Audi
[/TD]
[TD]579735
[/TD]
[TD]20 000
[/TD]
[/TR]
</tbody>[/TABLE]
I have:
If you know how can I add the proper number of rows please help me.
in filed I have couple of value separated by comma like below:
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]A1 header1
[/TD]
[TD]B1 header2
[/TD]
[TD]C1 header3
[/TD]
[/TR]
[TR]
[TD]Audi
[/TD]
[TD]592035, 579733, 653749, 579735
[/TD]
[TD]20 000
[/TD]
[/TR]
</tbody>[/TABLE]
If my macro found that string (always will be separate by ",") should split the string and add rows (= to number of string). The output should be as below:
[TABLE="class: grid, width: 300"]
<tbody>[TR]
[TD]A1 header1
[/TD]
[TD]B1 header2
[/TD]
[TD]C1 header3
[/TD]
[/TR]
[TR]
[TD]Audi
[/TD]
[TD]592035
[/TD]
[TD]20 000
[/TD]
[/TR]
[TR]
[TD]Audi
[/TD]
[TD]579733
[/TD]
[TD]20 000
[/TD]
[/TR]
[TR]
[TD]Audi
[/TD]
[TD]653749
[/TD]
[TD]20 000
[/TD]
[/TR]
[TR]
[TD]Audi
[/TD]
[TD]579735
[/TD]
[TD]20 000
[/TD]
[/TR]
</tbody>[/TABLE]
I have:
Code:
Set sourceWb = ActiveWorkbook
Set ws = sourceWb.Worksheets(1)
Dim LastRow As Long
Dim MY_Split As Variant
LastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row
For i = 2 To LastRow
If InStr(Range("D" & i).Value, ",") Then 'find the string
MY_Split = Split(Range("D" & i).Value, ",") 'split the string
'MsgBox UBound(MY_Split)
'how to add here the proper count of rows???
'For countIndex = LBound(MY_Split) To UBound(MY_Split) 'here I can fill the table
'Next
End If
Next i
End Sub
If you know how can I add the proper number of rows please help me.