+ Reply to Thread
Results 1 to 9 of 9

Split Text from cell

  1. #1
    Forum Contributor
    Join Date
    09-04-2013
    Location
    USA
    MS-Off Ver
    Excel 365
    Posts
    263

    Split Text from cell

    I have trying to split numbers from letter a cell. The numbers can appear before or after the text, and sometimes the numbers can have two hypens (for SSN), two forward slashes (/) for dates, or a decimal point and/or dollar sign. if the numbers appear first, I need them to stay in the activecell and move the letters one cell to the right. If the letters appear first in the cell, I need the numbers move one cell to the right.

    I have a script below that uses Regexp, the only problem is that is only works for the hypens and I need to add in the two backslashes, decimal point, and dollar sign. I tried a few variations but to no avail. Any ideas? Thanks..


    Please Login or Register  to view this content.

  2. #2
    Forum Contributor
    Join Date
    09-04-2013
    Location
    USA
    MS-Off Ver
    Excel 365
    Posts
    263

    Re: Split Text from cell

    I think I have it..the only thing I cannot figure out is the "literal" dollar sign that would be part of the number. Below is the revised code. Is there a way to set it up to ignore dollar signs?

    Please Login or Register  to view this content.

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Split Text from cell

    Hi,

    Are you sure you need a macro, and one requiring RegExp just to complicate it.
    Post examples of your text values since there's probably a straightforward string slicing function that will be easier and quicker.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Forum Contributor
    Join Date
    09-04-2013
    Location
    USA
    MS-Off Ver
    Excel 365
    Posts
    263

    Re: Split Text from cell

    No, it does not have to be RegEx. Whatever works is fine.

    See attached spreadsheet. Sheets labeled Before and After.

    Thanks.
    Attached Files Attached Files

  5. #5
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Split Text from cell

    Do you think a result of something like this would be helpful to you?

    A
    B
    1
    JohnSmith111-55-5678 111-55-5678
    2
    555-12-3456Parton,Dolly 555-12-3456
    3
    Holmes, john$55.45 55.45
    4
    SmithJohn12/56/1977 12/56/1977
    5
    12/25/1965JohnBarton 12/25/1965
    6
    AneSmith654 654
    7
    5673smith 5673
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  6. #6
    Forum Contributor
    Join Date
    09-04-2013
    Location
    USA
    MS-Off Ver
    Excel 365
    Posts
    263

    Re: Split Text from cell

    No, would need text and numbers separated. Also, it letters are first, then numbers would be shifted right, if numbers are first, then letters would be shifted right.

  7. #7
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Split Text from cell

    Try this UDF

    Please Login or Register  to view this content.
    Then use formulas
    for Split 1

    =IF(ISERROR(LEFT(A2)+0),NumberOut(A2),SUBSTITUTE(A2,NumberOut(A2),""))

    for Split 2

    =IF(ISNUMBER(LEFT(A2)+0),NumberOut(A2),SUBSTITUTE(A2,NumberOut(A2),""))

    or you can use =SUBSTITUTE(A2,B2,"") (for Split 2)

    A
    B
    C
    1
    Text Split 1 Split 2
    2
    JohnSmith111-55-5678 JohnSmith 111-55-5678
    3
    555-12-3456Parton,Dolly 555-12-3456 Parton,Dolly
    4
    Holmes, john$55.45 Holmes, john$ 55.45
    5
    SmithJohn12/56/1977 SmithJohn 12/56/1977
    6
    12/25/1965JohnBarton 12/25/1965 JohnBarton
    7
    AneSmith654 AneSmith 654
    8
    5673smith 5673 smith
    Last edited by AlKey; 06-01-2014 at 01:11 PM.

  8. #8
    Forum Contributor
    Join Date
    09-04-2013
    Location
    USA
    MS-Off Ver
    Excel 365
    Posts
    263

    Re: Split Text from cell

    Thanks. It worked.

  9. #9
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Split Text from cell

    You're welcome. Please don't forget to thank those who helped by clicking on Add Reputation *

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Split text in a cell
    By dougmorgan in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 05-23-2013, 12:48 PM
  2. Macro : Split text of a single cell into multiple cell
    By rampal in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-03-2012, 02:05 PM
  3. Split text in a cell
    By Ohio River Greg in forum Excel General
    Replies: 2
    Last Post: 10-03-2011, 03:44 PM
  4. split text from one cell
    By duda in forum Excel General
    Replies: 5
    Last Post: 01-17-2011, 04:40 PM
  5. Split text to next cell down
    By drawing.blanks in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-02-2009, 03:31 AM

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1