+ Reply to Thread
Results 1 to 13 of 13

Splitting hyphen-separated data into multiple cells

Hybrid View

  1. #1
    Registered User
    Join Date
    12-14-2014
    Location
    NJ
    MS-Off Ver
    2007
    Posts
    7

    Splitting hyphen-separated data into multiple cells

    Hello,

    I am looking to split hyphen-separated data into individual cells.

    The data is formatted like this:

    186.00000000 - 130.00000000 - 76.00000000 - 40.00000000
    30.00000000 - 39.00000000 - 24.00000000 - 4.00000000
    226.00000000 - 323.00000000 - 122.00000000 - 96.00000000
    6.00000000 - 1.00000000 - 5.00000000 - 5.00000000

    There is a space, hyphen, space between each number. Each number has eight decimal places, and an unknown number of significant digits. I would like to be able to extract each individual number into its own cell.

    I played around with nesting SEARCH and LEFT, MID, RIGHT position functions with no luck. I think I was on the right track, but couldn't get it to work.

    Any help is much appreciated.

    Josh

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Splitting hyphen-separated data into multiple cells

    Data > Text to columns, Delimited ...
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    12-14-2014
    Location
    NJ
    MS-Off Ver
    2007
    Posts
    7

    Re: Splitting hyphen-separated data into multiple cells

    Thanks shg. That is the method I've been using. I am trying to use formulas, so I can paste my data into a WIP tab and have the useful data populated into my formulated/formatted sheet.

    This is where I got the idea for the SEARCH and position formulas: https://support.office.com/en-ca/art...c-1bf66e219ea8
    Last edited by kilowhat; 12-14-2014 at 04:25 PM.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Splitting hyphen-separated data into multiple cells

    Row\Col
    A
    B
    C
    D
    E
    F
    1
    186.00000000 - 130.00000000 - 76.00000000 - 40.00000000 186.00000000 130.00000000 76.00000000 40.00000000 B1: =TRIM(MID(SUBSTITUTE($A1, "-", REPT(" ", 100)), 100*COLUMNS($B1:B1) - 99, 100))
    2
    30.00000000 - 39.00000000 - 24.00000000 - 4.00000000 30.00000000 39.00000000 24.00000000 4.00000000
    3
    226.00000000 - 323.00000000 - 122.00000000 - 96.00000000 226.00000000 323.00000000 122.00000000 96.00000000
    4
    6.00000000 - 1.00000000 - 5.00000000 - 5.00000000 6.00000000 1.00000000 5.00000000 5.00000000

  5. #5
    Registered User
    Join Date
    12-14-2014
    Location
    NJ
    MS-Off Ver
    2007
    Posts
    7

    Re: Splitting hyphen-separated data into multiple cells

    shg,

    Thank you, this is almost perfect. It returns an empty cell when there is a negative number (minus vs hyphen).

    e.g.,

    2.00000000 - 1.00000000 - 1.00000000 - -1.00000000
    32.00000000 - 0.00000000 - -1.00000000 - 2.00000000

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Splitting hyphen-separated data into multiple cells

    =trim(mid(substitute($a1, " - ", ...

  7. #7
    Registered User
    Join Date
    12-14-2014
    Location
    NJ
    MS-Off Ver
    2007
    Posts
    7

    Re: Splitting hyphen-separated data into multiple cells

    Thank you very much.

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Splitting hyphen-separated data into multiple cells

    You're welcome.

  9. #9
    Registered User
    Join Date
    12-14-2014
    Location
    NJ
    MS-Off Ver
    2007
    Posts
    7

    Re: Splitting hyphen-separated data into multiple cells

    If I overwrite the data in both columns 1 and 2, the slope formula works (for those two data points).
    Attachment 364834
    Last edited by kilowhat; 12-14-2014 at 09:31 PM.

  10. #10
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Splitting hyphen-separated data into multiple cells

    I didn't look at your file.

    The formulas to split the data are returning TEXT values even though they look like numbers.

    One way to convert them to numbers is use the double unary minus operation.

    --(formula)

    The inner - converts the text number to a negative numeric value.

    The outer - just reverses the numbers sign, from negative to positive.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  11. #11
    Registered User
    Join Date
    12-14-2014
    Location
    NJ
    MS-Off Ver
    2007
    Posts
    7

    Re: Splitting hyphen-separated data into multiple cells

    Worked perfectly. Thanks Tony.

  12. #12
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Splitting hyphen-separated data into multiple cells

    You're welcome. Thanks for the feedback!

  13. #13
    Registered User
    Join Date
    12-14-2014
    Location
    NJ
    MS-Off Ver
    2007
    Posts
    7

    Re: Splitting hyphen-separated data into multiple cells

    The formula is returning the number perfectly. I am using the four data points to calculate the slope of a line in a forecast. The headers for each column are 4,3,2,1 and are the X values in the slope. The slope formula is returning a divide by zero error when reading the data returned from your formula.

    The forecast formula works fine with keyed-in numbers, or pasted values.

    I attached a screenshot.

    Capture.JPG

+ 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] Merging two columuns into one, but having it separated by a hyphen
    By brlcarol99 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-08-2014, 12:20 PM
  2. [SOLVED] Splitting Cell that contains multiple Headers with Data separated by comma.
    By omershafiq2012 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-25-2014, 09:42 AM
  3. [SOLVED] Custom Formatting of nos. separated by hyphen
    By naira in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 05-27-2013, 10:56 PM
  4. Replies: 5
    Last Post: 02-22-2011, 06:28 AM
  5. Splitting comma separated cells
    By Dangermouse500 in forum Excel General
    Replies: 5
    Last Post: 02-20-2007, 01:29 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