+ Reply to Thread
Results 1 to 6 of 6

Output selection to a single string

  1. #1
    Registered User
    Join Date
    05-14-2009
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    2

    Output selection to a single string

    Hello,

    I'm completely new to VBA for excel and would greatly appreciate some guidance. The problem, is that I have a single column containing a list of IDs like this:

    002234
    000023
    022212
    023232
    021232

    My goal, is to format these IDs such that they are concatenated into a single string, with each ID separated by a semicolon. More importantly, I need to output the results to a text file. So the resulting text file would look like this:

    002234;000023;022212;023232;021232

    Would anyone be able to assist me?

  2. #2
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile Re: Output selection to a single string

    Good morning estimablesir

    ...and welcome to the forum!!
    Quote Originally Posted by estimablesir View Post
    My goal, is to format these IDs such that they are concatenated into a single string, with each ID separated by a semicolon. More importantly, I need to output the results to a text file.
    This code should do the trick. Amend the path as shown, select the range you want exporting to a textfile and run the macro.
    Please Login or Register  to view this content.
    HTH

    DominicB
    Please familiarise yourself with the rules before posting. You can find them here.

  3. #3
    Registered User
    Join Date
    05-14-2009
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Output selection to a single string

    Worked like a charm, thanks very much!

  4. #4
    Registered User
    Join Date
    12-17-2008
    Location
    Malaysia
    Posts
    12

    Re: Output selection to a single string

    Sorry. Need to bump here. How do I tweak it if my data is in rows and not column. I would like the string to be at the end of row.

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Output selection to a single string

    Please take a few minutes to read the forum rules, and then start your own thread.
    Entia non sunt multiplicanda sine necessitate

  6. #6
    Registered User
    Join Date
    12-17-2008
    Location
    Malaysia
    Posts
    12

    Re: Output selection to a single string

    Sorry. Will create a new one now.

+ 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