splitting cells based on commas

aaronnechama

New Member
Joined
Mar 11, 2009
Messages
6
How do I split a series of cells based on commas? There is a series of data in 2 consecutive cells, with the data in each cell corresponding to the data in the adjacent cell. I need that each pair should be lined up in separate columns. Here is the example:
excel-data-image.png


I need to match up the SKU with the corresponding Quantity in the adjacent column. Any ideas would be greatly appreciated.
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Not entirely sure what your desired output is... using formulae perhaps something like:

Excel Workbook
GHIJKLMNOPQRS
2a,b,c,d1,1,2,14abcd1121
3a,b1,12ab11
4s11s1
5apple,banana,carrot,donkey,elephant10,300,1,2,35applebananacarrotdonkeyelephant10300123
Sheet1


but you will need to first determine max no. of SKU's in any given line as this should dictate how many columns you setup for each section (SKU / Quantity), you can do this using by first inserting the formula provided in I and then running a MAX against this column.

You might want to think about VBA of course...
 
Upvote 0
may be this

Code:
Option Explicit
Function joins(ByVal ref1 As String, ByVal ref2 As String) As String
Dim i As Integer, arr1, arr2
arr1 = Split(ref1, ",")
arr2 = Split(ref2, ",")
'joins = ""
For i = LBound(arr1) To Application.Min(UBound(arr1), UBound(arr2))
    joins = Join(Array(joins, arr1(i), arr2(i)), ",")
Next
joins = Right(joins, Len(joins) - 1)
End Function
Excel Workbook
ABC
1a,b,c,d1,2,3,4a,1,b,2,c,3,d,4
Sheet1
Excel 2003
Cell Formulas
RangeFormula
C1=joins(A1,B1)
 
Upvote 0

Forum statistics

Threads
1,223,237
Messages
6,170,930
Members
452,367
Latest member
TePunaBloke

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