+ Reply to Thread
Results 1 to 9 of 9

Excel - VBA function to dissolve text string

  1. #1
    Registered User
    Join Date
    02-10-2018
    Location
    Oslo
    MS-Off Ver
    Office 13
    Posts
    3

    Excel - VBA function to dissolve text string

    Hey guys,

    Hope someone can help me with a VBA function I can not quite see how to solve. I have a long list of addresses, such as:

    Myrdalsvegen 10, 12, 14, Myrdalshovden 22, 26A-F, Bergen
    Moholt Allé 9, 11, 13, Fiolsvingen 3, 5, 7, Trondheim
    ...

    I'm trying to create a macro that extracts the individual address like this:

    Myrdalsvegen 10, Bergen
    Myrdalsvegen 12, Bergen
    Myrdalsvegen 14, Bergen
    Myrdalshovden 22, Bergen
    Myrdalshovden 26A-F, Bergen
    ...

    I have tried using LEFT, RIGHT, FIND in a loop, but it wasn't very elegant and didn't get the job done. Does anyone have any nice solutions or ideas on how to solve this? Would really appreciate the help.

    Thank you very much in advance.

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Excel - VBA function to dissolve text string

    Some selective splitting might work!

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Excel - VBA function to dissolve text string

    the data is too erratic in structure to use either formulas or VBA with any degree of accuracy for the output. The data would need to be a bit more organized with unique characters to separate the city grouping. Then it might be feasible to use something like a Split function to to produce the desired output. Unforutunately, the computer cannot think and has to be directed as to what it looks for logically. However, some might give it a try.
    Any code provided by me should be tested on a copy or a mock up of your original data before applying it to the original. Some events in VBA cannot be reversed with the undo facility in Excel. If your original post is satisfied, please mark the thread as "Solved". To upload a file, see the banner at top of this page.
    Just when I think I am smart, I learn something new!

  4. #4
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Excel - VBA function to dissolve text string

    If you'll post a sample, I'm willing to try it

  5. #5
    Registered User
    Join Date
    02-10-2018
    Location
    Oslo
    MS-Off Ver
    Office 13
    Posts
    3

    Re: Excel - VBA function to dissolve text string

    Hi again,

    Really appreciate you trying. I don't think it is impossible but certainly challenging. There is some sort of structure. The city is always last, after the last comma. The other ones are addresses. Also - it working in 90 % of the cases would still save me a ton of time. I would scan through after and fix the ones that are not done/done correctly by the macro. Thanks for helping
    Attached Files Attached Files

  6. #6
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Excel - VBA function to dissolve text string

    Try this:

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    02-10-2018
    Location
    Oslo
    MS-Off Ver
    Office 13
    Posts
    3

    Re: Excel - VBA function to dissolve text string

    Wow! That's amazing. Thank you so much

  8. #8
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Excel - VBA function to dissolve text string

    You're welcome and thanks for the rep!

  9. #9
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Excel - VBA function to dissolve text string

    Hi Grupper,

    If the Queue would only be 10 or less times longer then this version will run rather quickly:

    Please Login or Register  to view this content.

+ 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. [SOLVED] Linear Values Dissolve
    By Huskersippi in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-02-2017, 05:55 PM
  2. Replies: 5
    Last Post: 02-11-2015, 10:41 PM
  3. Advanced Split Function: Need to pull text string in quotes, within a text string
    By Zamboni in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-27-2013, 04:38 PM
  4. Can you use an excel function to isolate part of a text string?
    By CharCat in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 09-27-2012, 02:05 AM
  5. String function to get selective text from long string
    By MWHLFC in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-29-2011, 02:51 PM
  6. string function to get selective text from long string
    By MWHLFC in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-25-2011, 05:00 PM
  7. Dissolve One Field, Append to another
    By floyd434 in forum Excel General
    Replies: 15
    Last Post: 09-22-2010, 05:02 PM

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