Split cell value where ", " to new cell

hajiali

Well-known Member
Joined
Sep 8, 2018
Messages
624
Office Version
  1. 2016
Platform
  1. Windows
Hello everyone,

Im needing help with the following
in column A I have String with commas

ex:
Book9
ABCDEFGHIJ
11,OFF,03 TP 2-1,03 TP 2-1,03 TP 2-1,03 TP 2-1,03 TP 2-1,OFF,1
Sheet1


what I need done is a macro that will split the value where ", " to its once cell next to A so the result for the above should be the following:

Book9
ABCDEFGHIJ
11,OFF,03 TP 2-1,03 TP 2-1,03 TP 2-1,03 TP 2-1,03 TP 2-1,OFF,11OFF03 TP 2-103 TP 2-103 TP 2-13 TP 2-13 TP 2-1OFF1
Sheet1


I will have multiple Rows so needs to run to the last row in column A. Any help is greatly appreciated.

Book9
A
11,OFF,03 TP 2-1,03 TP 2-1,03 TP 2-1,03 TP 2-1,03 TP 2-1,OFF,1
22,OFF,04 TP 2-4,03C TP 2-2,03C TP 2-2,03C TP 2-2,03C TP 2-2,OFF,2
33,OFF,04 TP 2-2,03C TP 1-2,03C TP 1-2,03C TP 1-2,03C TP 1-2,OFF,2
44,OFF,OFF,03 TP 1-4,03 TP 1-4,03 TP 1-4,03 TP 1-4,03 TP 2-1,1
55,OFF,OFF,03B TP 2-4,03B TP 2-4,03B TP 2-4,03B TP 2-4,03B TP 2-4,1
66,OFF,OFF,05 TP/BR,05 TP/BR,05 TP/BR,05 TP/BR,05 TP/BR,1
77,03 TP 2-1,OFF,OFF,03 TP 1-1,03 TP 1-1,03 TP 1-1,03 TP 1-4,1
88,05 TP/BR,OFF,OFF,05 TP/BR,05 TP/BR,05 TP/BR,05 TP/BR,1
99,06 TP 2-3,OFF,OFF,05B TP 2-3,05B TP 2-3,05B TP 2-3,05B TP 2-3,2
1010,03 TP 1-4,03 TP 1-4,OFF,OFF,04 TP 2-5,04 TP 2-5,03 TP 1-1,2
1111,04 TP 2-4,04 TP 1-5,OFF,OFF,04 TP 1-5,04 TP 1-5,04 TP 2-2,1
1212,04B TP/BR,04B TP 2-5,OFF,OFF,04B Misfits,04B Misfits,04B TP 2-5,1
1313,03 TP 1-1,03 TP 1-1,03 TP 1-1,OFF,OFF,03 Misfits,03 Misfits,1
1414,05 TP/BR,05 TP/BR,05 TP/BR,OFF,OFF,05 TP/BR,05 TP/BR,1
1515,05B TP 2-5,05 TP/BR,05B TP 2-3,OFF,OFF,05 TP 1-3,05 TP 1-3,2
1616,04 TP 2-2,04 TP 1-2,04 TP 2-5,04 TP 2-5,OFF,OFF,04 TP 1-5,1
1717,04 TP 1-2,04 Misfits,04 TP 1-5,04 TP 1-5,OFF,OFF,04 TP 1-2,1
1818,04B Misfits,04B TP 1-3,04B Misfits,04B Misfits,OFF,OFF,04B Misfits,1
1919,03 Misfits,03 Misfits,03 Misfits,03 Misfits,03 Misfits,OFF,OFF,1
2020,05 TP 1-5,05 TP 2-3,05 TP 1-3,05 TP 1-3,05 TP 1-3,OFF,OFF,1
2121,06 TP 1-3,05 TP/BR,05 TP/BR,05 TP/BR,05 TP/BR,OFF,OFF,2
Sheet1
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
You don't need VBA to do this.
Just use "Text to Columns" from the Data menu, selecting the comma as your delimiter, and it will do precisely that.

If you want/need it in VBA code, just turn on the Macro Recorder, and record yourself doing this with Text to Columns, and you will have the code that you need.
 
Upvote 0
How about
VBA Code:
Sub hajiali()
   Dim Cl As Range
   Dim Sp As Variant
   
   For Each Cl In Range("A1", Range("A" & Rows.Count).End(xlUp))
      Sp = Split(Cl.Value, ",")
      Cl.Offset(, 1).Resize(, UBound(Sp) + 1).Value = Sp
   Next Cl
End Sub
 
Upvote 0
Solution
Much appreciate the quick response everyone. Thank you so much Fluff works great
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,911
Messages
6,122,192
Members
449,072
Latest member
DW Draft

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