+ Reply to Thread
Results 1 to 5 of 5

Thread: Help with splitting contents of a cell

  1. #1
    Registered User
    Join Date
    12-24-2010
    Location
    Ohio
    MS-Off Ver
    Excel 2007
    Posts
    87

    Help with splitting contents of a cell

    Morning,


    I can't remember how to split the contents of a cell into different cells.

    Currently I have:
    A1 = 41-33.91
    would like to have:
    B1 = 41
    C1 = 33
    D1 = 91

    A2 = 41-38.00

    B2 = 41
    C2 = 38
    D2 = 00
    etc.

    Ideally would like to have it in VBA because I have 5345 rows that needs to be split, but a formula would be fine. I would just copy the formula into the other cells.

    Thanks in advance,

    George
    Last edited by BigGPL; 01-22-2012 at 06:21 AM. Reason: Solved

  2. #2
    Valued Forum Contributor dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    New Delhi, India
    MS-Off Ver
    Excel 1997, 2000, XP, 2003, 2007, 2010
    Posts
    2,365

    Re: Help with splitting contents of a cell

    Hi George,

    Which format do you want for extracted data- Text or Number?

    Regards,
    DILIPandey

    <click on below 'star' if this helps>
    DILIPandey
    +919810929744
    dilipandey@gmail.com

  3. #3
    Valued Forum Contributor dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    New Delhi, India
    MS-Off Ver
    Excel 1997, 2000, XP, 2003, 2007, 2010
    Posts
    2,365

    Re: Help with splitting contents of a cell

    Hi George,

    Basis your data, use following formulas for column B, C and D respectively.

    Note: Extracted data numbers would be in text format.

    
    =LEFT(A2,2)
    =MID(A2,4,2)
    =RIGHT(A2,2)
    Regards,
    DILIPandey

    <click on below 'star' if this helps>
    DILIPandey
    +919810929744
    dilipandey@gmail.com

  4. #4
    Forum Guru mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2007/2010
    Posts
    3,004

    Re: Help with splitting contents of a cell

    VBA

    Sub Test()
    For N = 1 To Cells(Rows.Count, 1).End(xlUp).Row
        Range(Cells(N, 2), Cells(N, 4)).NumberFormat = "@"
        Cells(N, 2) = Left(Cells(N, 1), InStr(Cells(N, 1), "-") - 1)
        Cells(N, 3) = Mid(Cells(N, 1), InStr(Cells(N, 1), "-") + 1, InStr(Cells(N, 1), ".") - InStr(Cells(N, 1), "-") - 1)
        Cells(N, 4) = Right(Cells(N, 1), Len(Cells(N, 1)) - InStr(Cells(N, 1), "."))
    Next N
    End Sub
    Formulae
    B1
    =LEFT(A1,FIND("-",A1)-1)

    C1
    =MID(A1,FIND("-",A1)+1,FIND(".",A1)-FIND("-",A1)-1)

    D1
    =RIGHT(A1,LEN(A1)-FIND(".",A1))
    Martin

    Eighty Twenty Spreadsheet Automation http://homepage.ntlworld.com/martin.rice1/ for all your Excel customisation and consulting needs.

    If my solution has saved you time and/or money, please consider donating to Cancer Research UK.

  5. #5
    Registered User
    Join Date
    12-24-2010
    Location
    Ohio
    MS-Off Ver
    Excel 2007
    Posts
    87

    Re: Help with splitting contents of a cell

    Hey guys


    Thanks for the replies. Decided to go with mrice's suggestion.

    George

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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.2.0