+ Reply to Thread
Results 1 to 12 of 12

Cell Splitting Formula

  1. #1
    Registered User
    Join Date
    08-13-2010
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    6

    Cell Splitting Formula

    Hi all,

    I am new to excel formulas, and have been trying to split a cell but just dont have the know how on how to do it.

    What I am trying to do is split a cell with data like this:

    cell A1: Devon 50.50N 03.55W SX9068

    in to four cells like this:

    cell A1: Devon
    cell A2: 50.50N
    cell A3: 03.55W
    cell A4: SX9068

    another example:

    cell B1: Sir Gaerfyrddin (Carmarthenshire) 51.68N 04.14W SN5201

    to

    cell B1: Sir Gaerfyrddin (Carmarthenshire)
    cell B1: 51.68N
    cell B1: 04.14W
    cell B1: SN5201

    Ideally I need this to work on an entire column and not just one cell at a time. any feedback is very welcome.
    Last edited by Pauled; 08-13-2010 at 01:54 PM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Cell Splitting Formula

    Wouldn't it be cleaner to break the values out from A1 into A1,B1,C1,D1, then repeat all the way down the column? Much simpler, too, from a programming standpoint.

    This it the Programming Forum, but your question sounds like you want a formula. Did you mispeak or mispost?
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    08-13-2010
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Cell Splitting Formula

    Quote Originally Posted by JBeaucaire View Post
    Wouldn't it be cleaner to break the values out from A1 into A1,B1,C1,D1, then repeat all the way down the column? Much simpler, too, from a programming standpoint.

    This it the Programming Forum, but your question sounds like you want a formula. Did you mispeak or mispost?
    It may be cleaner, but firstly I have a spreadsheet with all the data listed in column A. Secondly, after this split I need to enter data between the columns, for which I intend to insert columns between these splits.

    (This is my first post, looking at the list of forums I thought this was closest related to formulas)

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Cell Splitting Formula

    Create a sample workbook with 4-5 of these sample strings as they exist in your data in the correct placement.

    Then add an AFTER sheet to the workbook showing the same data split the way you want including the stuff you're going to do next. If we're going to construct a macro to split, it can most like make the insertions and such you need as well.

  5. #5
    Registered User
    Join Date
    08-13-2010
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Cell Splitting Formula

    Quote Originally Posted by JBeaucaire View Post
    Create a sample workbook with 4-5 of these sample strings as they exist in your data in the correct placement.

    Then add an AFTER sheet to the workbook showing the same data split the way you want including the stuff you're going to do next. If we're going to construct a macro to split, it can most like make the insertions and such you need as well.
    Think I done it right...
    Attached Files Attached Files

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Cell Splitting Formula

    None of those example include the parenthetical examples from the original post.

    Also, we're just dropping the last part of each string?

  7. #7
    Registered User
    Join Date
    08-13-2010
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Cell Splitting Formula

    Quote Originally Posted by JBeaucaire View Post
    None of those example include the parenthetical examples from the original post.

    Also, we're just dropping the last part of each string?
    Maybe that was a bad example, but the first and second text elements are locations and so can include (),'-_. Yes I do wish to drop that last section of the string.

  8. #8
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Cell Splitting Formula

    Try this:
    Please Login or Register  to view this content.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    08-13-2010
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Cell Splitting Formula

    Quote Originally Posted by JBeaucaire View Post
    Try this:
    Please Login or Register  to view this content.
    Thank you very much for going to this trouble for me. But where do I need to enter that script? Im very new to this.

  10. #10
    Registered User
    Join Date
    08-13-2010
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Cell Splitting Formula

    I believe I have sussed it, but I got a Run Time Error '9': Sub Script out of range error: .Range("D" & Rw) = Trim(MyArr(UBound(MyArr) - 1))
    Last edited by Pauled; 08-13-2010 at 04:50 PM.

  11. #11
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Cell Splitting Formula

    It's already IN the sample sheet I uploaded, just press F8 and run it.

    ============
    How/Where to install the macro:

    1. Open up your workbook
    2. Get into VB Editor (Press Alt+F11)
    3. Insert a new module (Insert > Module)
    4. Copy and Paste in your code (given above)
    5. Get out of VBA (Press Alt+Q)
    6. Save as a macro-enabled workbook

    Try not to quote my entire post, just use the quick reply instead of quote.

  12. #12
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Cell Splitting Formula

    Quote Originally Posted by Pauled View Post
    I believe I have sussed it, but I got a Run Time Error '9': Sub Script out of range error: .Range("D" & Rw) = Trim(MyArr(UBound(MyArr) - 1))
    Please provide the value of RW at the time of debugging. Also, what is the string being evaluated?

+ 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.6.0 RC 1