Sentence cutting

santeri

New Member
Joined
Mar 21, 2016
Messages
1
Hello,

I was wondering if there is a way to cut words from sentences ? My problem is that i have information that is in one cell and i need to cut it apart in different cells. I could do it manualy but there are thousands of sheets like this.

Example

Johan dohan, snippersnapper, jorgen 21, fasaani

And i need to get it in different cell cutting from every comma.

Johan dohan
snippersnapper
jorgen 21
fasaani

Thanks
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
santeri,

Welcome to the MrExcel forum.

If I understand you correctly, then here is a macro for you to consider, that is based on the raw data (plus) that you have displayed.

Sample raw data, and, results in the active worksheet:


Excel 2007
ABC
1Johan dohan, snippersnapper, jorgen 21, fasaaniJohan dohan
2snippersnapper2, fasaani2, jorgen 212, Johan dohan2snippersnapper
3jorgen 21
4fasaani
5snippersnapper2
6fasaani2
7jorgen 212
8Johan dohan2
9
Sheet1


Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).

Code:
Sub ReorgData()
' hiker95, 03/21/2016, ME929486
Dim r As Range, s, i As Long, nr As Long
Application.ScreenUpdating = False
With ActiveSheet
  nr = 1
  For Each r In .Range("A1", .Range("A" & Rows.Count).End(xlUp))
    If InStr(r, ", ") Then
      s = Split(r, ", ")
      .Cells(nr, 3).Resize(UBound(s) + 1).Value = Application.Transpose(s)
      nr = nr + UBound(s) + 1
    End If
  Next r
  .Columns(3).AutoFit
End With
Application.ScreenUpdating = True
End Sub

If you are new to macros, they are easy to install and use. To install it, simply press ALT+F11 to go into the VB editor and, once there, click Insert/Module on its menu bar, then copy/paste the above code into the code window that just opened up. That's it.... you are done. To use the macro, go back to the worksheet with your data on it and press ALT+F8, select the macro name ( ReorgData ) from the list that appears and click the Run button. The macro will execute and perform the action(s) you asked for. If you will need to do this again in this same workbook, and if you are using XL2007 or above, make sure you save your file as an "Excel Macro-Enabled Workbook (*.xlsm) and answer the "do you want to enable macros" question as "yes" or "OK" (depending on the button label for your version of Excel) the next time you open your workbook.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,834
Messages
6,121,876
Members
449,056
Latest member
ruhulaminappu

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