Consulting

Results 1 to 6 of 6

Thread: Split two different columns with two different addresses

  1. #1
    VBAX Newbie
    Joined
    Oct 2023
    Posts
    5
    Location

    Split two different columns with two different addresses

    Hi,

    I have attached a file with some data that needs splitting, there is no common delimiter.

    I managed to get half way there but then get more issues.

    Anyone able to help me. I need to get column D split out into new columns titled Address Line 1, Address Line 2, City, County. Then we need to do exactly the same for Column H, however this will also need to merge into column I as some have postcodes already and some are in the delivery address.

    Please help me VBA Kenobi!!
    Attached Files Attached Files

  2. #2
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,064
    Location
    Use the TextSplit function as in select a empty column
    For Column D
    =TextSplit(D2,",")
    and copy down
    For Column H
    =Textsplit(H2,",")
    and copy down.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  3. #3
    VBAX Newbie
    Joined
    Oct 2023
    Posts
    5
    Location
    Quote Originally Posted by Aussiebear View Post
    Use the TextSplit function as in select a empty column
    For Column D
    =TextSplit(D2,",")
    and copy down
    For Column H
    =Textsplit(H2,",")
    and copy down.
    Unfortunately this would only work if the delimiter is the same. However, this is not. Delimeter can be not there, and obviously road names can have spaces in for the road name.

  4. #4
    Moderator VBAX Master georgiboy's Avatar
    Joined
    Mar 2008
    Location
    Kent, England
    Posts
    1,198
    Location
    How about the attached, i have created a lookup on sheet2 that contains the variations of how the (road, close, crescent, way, etc...) end, i have used this to create the below formula:

    Address part1:
    =LET( ts,TEXTSPLIT(SUBSTITUTE(D2,","," ")," "),
     TRIM(TEXTJOIN(" ",,CHOOSECOLS(ts,SEQUENCE(,MIN(TOCOL(MATCH(Sheet2!$A$1:$A$6,ts,0),3))))))
    )
    Address part2:
    =TRIM(SUBSTITUTE(SUBSTITUTE(D2,","," "),E2,""))
    Attached Files Attached Files
    Click here for a guide on how to add code tags
    Click here for a guide on how to mark a thread as solved
    Click here for a guide on how to upload a file with your post

    Excel 365, Version 2403, Build 17425.20146

  5. #5
    VBAX Newbie
    Joined
    Oct 2023
    Posts
    5
    Location
    Quote Originally Posted by georgiboy View Post
    How about the attached, i have created a lookup on sheet2 that contains the variations of how the (road, close, crescent, way, etc...) end, i have used this to create the below formula:

    Address part1:
    =LET( ts,TEXTSPLIT(SUBSTITUTE(D2,","," ")," "),
     TRIM(TEXTJOIN(" ",,CHOOSECOLS(ts,SEQUENCE(,MIN(TOCOL(MATCH(Sheet2!$A$1:$A$6,ts,0),3))))))
    )
    Address part2:
    =TRIM(SUBSTITUTE(SUBSTITUTE(D2,","," "),E2,""))
    Was looking for more VBA so user can just copy and paste in, using a lookup against end of roads doesn't work either as some may just be one word.

  6. #6
    Moderator VBAX Master georgiboy's Avatar
    Joined
    Mar 2008
    Location
    Kent, England
    Posts
    1,198
    Location
    In such a scenario, I can only extend my best wishes to you in your quest to discover a solution.


    Based on my background in the transportation industry, I've noticed that the initial lines of most addresses frequently culminate with terms like 'Road,' 'Close,' 'Crescent,' 'Way,' 'Estate,' 'Street,' and similar designations. This pattern is also evident in all the instances within your sample data.


    Even when using VBA, I believe it would be essential to utilise a lookup list, as I can't discern a programmatic approach to effectively segment the data.
    Click here for a guide on how to add code tags
    Click here for a guide on how to mark a thread as solved
    Click here for a guide on how to upload a file with your post

    Excel 365, Version 2403, Build 17425.20146

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •