Data sorting

Moharam

New Member
Joined
Jan 5, 2022
Messages
8
Office Version
  1. 2016
  2. 2007
Platform
  1. Windows
Hi Guys please help me with this, I need to sort this as per below criteria.

Data.xlsx
ABC
1Actual Data
2Order IDProductsQty
32018000499421D Capsules,C Cider Vinegar,AB Oil2,1,1
42018000486403D Capsules,C Cider Vinegar,AB Oil2,1,1
52018000499744S Xtreme Power - 1,C Cider Vinegar,D Capsules,AB Oil1,1,2,1
6
7
8Required Data
9Order IDProductsQty
102018000499421D Capsules2
112018000499421C Cider Vinegar1
122018000499421AB Oil1
132018000486403D Capsules2
142018000486403C Cider Vinegar1
152018000486403AB Oil1
162018000499744S Xtreme Power - 11
172018000499744C Cider Vinegar1
182018000499744D Capsules2
192018000499744AB Oil1
Sheet1
 
In column 2 are more comma,s. So when you split both column 2 and 3 with comma's, you will have different array sizes...
 
Upvote 0

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
One suggestion

VBA Code:
Sub jec()
 Dim ar, jv, sp As Variant, i As Long, j As Long, x As Long
 ar = Cells(1).CurrentRegion
 ReDim jv(2, 0)
 
 For i = 2 To UBound(ar)
    sp = Split(Replace(ar(i, 2), " , ", " "), ",")
    For j = 0 To UBound(sp)
       ReDim Preserve jv(2, x)
        jv(0, x) = ar(i, 1)
        jv(1, x) = sp(j)
        jv(2, x) = Split(ar(i, 3), ",")(j)
        x = x + 1
     Next
 Next
 
 Cells(1, 7).Resize(x, 3) = Application.Transpose(jv)
End Sub
 
Upvote 0
One suggestion

VBA Code:
Sub jec()
 Dim ar, jv, sp As Variant, i As Long, j As Long, x As Long
 ar = Cells(1).CurrentRegion
 ReDim jv(2, 0)
 
 For i = 2 To UBound(ar)
    sp = Split(Replace(ar(i, 2), " , ", " "), ",")
    For j = 0 To UBound(sp)
       ReDim Preserve jv(2, x)
        jv(0, x) = ar(i, 1)
        jv(1, x) = sp(j)
        jv(2, x) = Split(ar(i, 3), ",")(j)
        x = x + 1
     Next
 Next
 
 Cells(1, 7).Resize(x, 3) = Application.Transpose(jv)
End Sub
Still the same Issue, It's only considering the first row. Can you please provide your email so I can mail you the entire file.
 
Upvote 0

Forum statistics

Threads
1,224,828
Messages
6,181,215
Members
453,024
Latest member
Wingit77

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