+ Reply to Thread
Results 1 to 8 of 8

Separating a string of data from one cell into separate cells

  1. #1
    Registered User
    Join Date
    11-01-2012
    Location
    Texas, USA
    MS-Off Ver
    Excel 2013
    Posts
    30

    Separating a string of data from one cell into separate cells

    I need to separate my data into separate columns for mailing purposes. I pull my data from an outside data source and it is formatted into 2 columns: Name and Address. It needs to be separated into the following columns: First, Last, Address, City, State, and Zip Code, for another department to generate mailing labels.

    My current first column is Last name, First name, Credentials (MD/DO etc). The next column is Street address City, ST, Zip. (Please note there is no punctuation between the street address and the city. This is the way it is pulled from our outside source. Possibly some addresses may be listed as 123 15th St or 12987 New York Avenue or 6875 Eagleview. There is not a consistent format in the addresses.)

    The names must be reflected as First Name Last Name, MD. Since the first name is currently between the last name and initials, I am stuck. I am also stuck as to how to differentiate the street address and the city.

    I have attached my worksheet with these scenarios. Thank you so much for your help.

    Sheila
    Attached Files Attached Files

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2406 Win 11 Home 64 Bit
    Posts
    23,982

    Re: Separating a string of data from one cell into separate cells

    Using Power Query, I have been able to address all the issues except for separating the City from the address. Look at the attached. Hopefully someone with a little bit more skill can figure that part out.

    Here is the MCode for that

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Separating a string of data from one cell into separate cells

    The difficult bit is the Address and City since the number of words in each field will vary. The other fields are easy.

    If the data is coming from an outside source why isn't it possible to output separate fields.
    Most back office systems can oputput csv files. I'd be inclined to look a bit more into getting the right information in the first place rather than trying to split strings as you're attempting here.

    Uisng a test row 9
    The First Name:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Last Name:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    State:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Zip:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Last edited by Richard Buttrey; 01-14-2019 at 02:27 PM.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Registered User
    Join Date
    11-01-2012
    Location
    Texas, USA
    MS-Off Ver
    Excel 2013
    Posts
    30

    Re: Separating a string of data from one cell into separate cells

    Wow, I have no idea what to do with this. I was just looking for formulas! I have never done anything Power Query. There is another girl in my office who might understand this. We will see what we can do with with this.

    As for the city/address issue, once we have gotten it this far, could we not just search the cell from the right for the space (which should be the city, unless it is two words. We could just do a visual check to see if there are any two word cities and manually fix these.)

    Thanks for your help.

  5. #5
    Registered User
    Join Date
    11-01-2012
    Location
    Texas, USA
    MS-Off Ver
    Excel 2013
    Posts
    30

    Re: Separating a string of data from one cell into separate cells

    It might be possible; but this outside source does not like to make changes like this. Also, we need this fairly quick (like today).

  6. #6
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2406 Win 11 Home 64 Bit
    Posts
    23,982

    Re: Separating a string of data from one cell into separate cells

    Open Power Query/Get and Transform. Click on New Query.

    Open blank query in the editor, launch Advanced Editor and paste in the code I gave you above. Make sure that your raw data is named Table1.

  7. #7
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Separating a string of data from one cell into separate cells

    OK, in addition to my previous formulae

    Address:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    City:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    You'll need to eyeball the city results where a City comprises two words.

  8. #8
    Registered User
    Join Date
    11-01-2012
    Location
    Texas, USA
    MS-Off Ver
    Excel 2013
    Posts
    30

    Re: Separating a string of data from one cell into separate cells

    Thank you, guys for your help. You all are AWESOME!!!! I am so glad I found this site. I use formulas quite a bit; but sometimes I need nudges or total help with something. My mind sometimes just wants to sleep and will not think the steps clearly. This site has helped me so many times; even reading other posts and seeing the answers given.

    Have a great day!

+ 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. Separating data into separate sheets
    By m4g63spd in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-12-2018, 02:39 PM
  2. Problem separating a long string into four separate fields?
    By colgor in forum Excel Formulas & Functions
    Replies: 24
    Last Post: 06-15-2016, 03:04 PM
  3. Separating data into separate cells
    By lauracvp in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-16-2016, 12:39 PM
  4. [SOLVED] Split a string of data among separate cells
    By rodrignj in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 02-14-2013, 10:18 AM
  5. Separate out a text string in one cell, and break into into individual cells
    By StephenHall in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 11-05-2012, 03:45 PM
  6. Separating an address string into separate parts using vba
    By adhbrown in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-30-2010, 04:08 PM
  7. Separating cell data into 2 new cells.
    By Joe@WSC in forum Excel - New Users/Basics
    Replies: 0
    Last Post: 07-07-2009, 10:10 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