+ Reply to Thread
Results 1 to 6 of 6

Macro attempting to split cells containing multiple co-ordinates into appropriate columns

  1. #1
    Registered User
    Join Date
    09-06-2013
    Location
    Northamptonshire, England
    MS-Off Ver
    Excel 2003
    Posts
    45

    Macro attempting to split cells containing multiple co-ordinates into appropriate columns

    Hi Everyone,

    I am currently attempting to split cells that contain an undetermined amount of Co-Ordinates (in the format of 'LINESTRING(X Y Z,X Y Z,X Y Z)' etc) into appropriate columns in a spreadsheet.

    Due to the fact that the cell can potentially contain between 2 and an infinite number of X Y Z co ordinates i am looking to extract only the first and last sets and delete the Z co-ordinate from each set. The resulting outcome would ideally be:

    First X Co-ordinate | First Y Co-ordinate | Second X Co-ordinate | Second Y Co-ordinate
    X| Y| X| Y

    Due to the fact that each co-ordinate is separated by a space, as far as i can gather the best way to do this would be to select the individual co ordinates by extracting them based on the position of spaces in the cell?

    (In addition the Z co-ordinate does not always populate so it is not possible to achieve this by counting a number of characters to the left or right to determine the correct point in which to split the cell)

    I would appreciate any and all assistance as i'm a little stumped at the moment.

    Thank you all in advance
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: Macro attempting to split cells containing multiple co-ordinates into appropriate colu


    Hi,

    see Split and UBound functions in VBA inner help …

  3. #3
    Valued Forum Contributor bulina2k's Avatar
    Join Date
    11-20-2012
    Location
    Urziceni, Ialomita, Romania
    MS-Off Ver
    2019 and 365
    Posts
    861

    Re: Macro attempting to split cells containing multiple co-ordinates into appropriate colu

    Hi there,


    Please Login or Register  to view this content.
    Attached Files Attached Files
    .. and don't forget to have fun!
    Bogdan.

    mark SOLVED and Add Reputation if my answer pleases you

  4. #4
    Registered User
    Join Date
    09-06-2013
    Location
    Northamptonshire, England
    MS-Off Ver
    Excel 2003
    Posts
    45

    Re: Macro attempting to split cells containing multiple co-ordinates into appropriate colu

    Hi Bulina2k,

    Thank you for your solution. It seems to work perfectly for examples where there are 2 sets of co ordinates, however when there are more than 2 it appears to return the second set and not the final set.

    Is there a slight alteration that i should make to amend this?

  5. #5
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Macro attempting to split cells containing multiple co-ordinates into appropriate colu

    See if this works
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    09-06-2013
    Location
    Northamptonshire, England
    MS-Off Ver
    Excel 2003
    Posts
    45

    Re: Macro attempting to split cells containing multiple co-ordinates into appropriate colu

    Brilliant.

    Thanks both of you. Made a couple of minor tweaks to your solution Stephen and it works perfectly.

    Much appreciated for both of your time.

+ 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. Macro to split Cells delimter comma to multiple Rows.
    By pavan5183 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-17-2013, 10:24 AM
  2. Replies: 2
    Last Post: 11-12-2012, 02:49 PM
  3. [SOLVED] Need macro to split one column into multiple columns based on _ and spacing
    By snely in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 09-17-2012, 10:05 AM
  4. Replies: 1
    Last Post: 08-24-2012, 02:56 AM
  5. Putting co ordinates into excel cells using a macro
    By helium in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-19-2012, 10:08 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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1