Results 1 to 5 of 5

Thread: How split a sentence into Word in Microsoft Excel

  1. #1
    Join Date
    Jan 2012
    Posts
    25

    How split a sentence into Word in Microsoft Excel

    Does anybody know of a formula that can look at a sentence of say 3 or 4 words and then look for the spaces in between the words and put each word in a different cell underneath each other.

  2. #2
    Join Date
    Aug 2011
    Posts
    695

    Re: How split a sentence into Word in Microsoft Excel

    You can just about do it with worksheet functions, but it's rather long-winded (and dependent on correct input).
    With the sentence in A1
    A2: =LEFT(A1,FIND(" ",A1)-1)
    A3: =MID(A1,FIND(" ",A1)+1,FIND(" ",A1,FIND(" ",A1)+1)-FIND(" ",A1)-1)
    A4: "and so on"
    It's a bit easier if you have some helper cells that just contain the positions of the spaces:
    A2: =FIND(" ",$A$1)
    A3: =FIND(" ",$A$1&" ",A2+1) ' append space to avoid special case for
    last word
    and copy the A3 down a few rows
    B2: =LEFT($A$1,A2-1)
    B3 =MID($A$1,A2+1,A3-A2-1)
    and copy B3 down.

  3. #3
    Join Date
    Mar 2011
    Posts
    542

    Re: How split a sentence into Word in Microsoft Excel

    VBA has a function named SPLIT which does what you want. The syntax for the function is SPLIT(String value, Delimiter). If you place a sentence in column A row 1 of Sheet 1, and place another in column a row 2, you can run the following code to parse the words separated by spaces and place them on sheet 2 column A in a column. Hope it helps to point you in the general direction.
    Code:
    Sub SplitSentences()
    Dim wb As Workbook
    Dim ws1 As Worksheet
    Dim ws2 As Worksheet
    Dim l As Long
    Dim strSentence As String
    Dim varArray As Variant
    Dim varItems As Variant
    Set wb = ActiveWorkbook
    Set ws1 = wb.Sheets("Sheet1")
    Set ws2 = wb.Sheets("Sheet2")
    ws1.Activate
    Range("A1").Select
    strSentence = ActiveCell.Value
    Do Until strSentence = ""
    ws2.Activate
    Range("A1").Select
    varArray = Split(strSentence, " ")
    varItems = varArray
    For Each varItems In varArray
    ActiveCell.Offset(l).Value = varItems
    l = l + 1
    Next varItems
    ws1.Activate
    ActiveCell.Offset(1).Select
    strSentence = ActiveCell.Value
    Loop
    Set wb = Nothing
    Set ws1 = Nothing
    Set ws2 = Nothing

  4. #4
    Join Date
    May 2011
    Posts
    448

    Re: How split a sentence into Word in Microsoft Excel

    There are two methods that you can try out. First use the Data/Text to Columns wizard with <space> as the delimiter. And the second option is by downloading and installing a morefunc.xll add-in program which is freely available on internet. Then, with your sentence in A1: B1: =REGEX.MID($A1,"\w+",COLUMNS($A:A)) and copy/drag across as far as needed. If it is an issue, there is an option to distribute the morefunc.xll add-in with the workbook.

  5. #5
    Join Date
    Jun 2011
    Posts
    798

    Re: How split a sentence into Word in Microsoft Excel

    You will first need to transpose the data to be in one column only.
    • Select the column you want to split
    • In the Data menu, select Text to Columns
    • Select Delimited and then click Next
    • Check only the box next to Space, and maybe the one next to Treat consecutive delimiters as one and then click Finish
    • This will split all cells in the column you selected and push the words to the right in other cells as you described you need. You can then tranpose the data to get the orientation you want.

Similar Threads

  1. Replies: 2
    Last Post: 15-02-2012, 08:17 PM
  2. How to Split a Single Cell in Microsoft Excel 2007
    By Corey Dunnett in forum Windows Software
    Replies: 2
    Last Post: 11-01-2012, 12:48 PM
  3. Replies: 7
    Last Post: 12-11-2011, 05:25 AM
  4. Replies: 1
    Last Post: 27-03-2011, 07:06 PM
  5. My Microsoft Word and Excel hangs up.
    By Dharmavira in forum Windows Software
    Replies: 2
    Last Post: 14-02-2009, 12:47 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,853,772.86017 seconds with 17 queries