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

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
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,214,391
Messages
6,119,244
Members
448,879
Latest member
VanGirl

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