+ Reply to Thread
Results 1 to 5 of 5

excel vba to separate single column entries into database format

  1. #1
    Registered User
    Join Date
    11-08-2012
    Location
    Seoul, Korea
    MS-Off Ver
    Excel 2007
    Posts
    3

    excel vba to separate single column entries into database format

    thank you for your reply...

    here's an excerpt of the original text file...

    the length of each message is random...the only regularly occurring delimiters are as I previously mentioned...

    also, another regular occurrence is that there are two lines that distinguish each message...

    text sample.txt





    hi...I'm a completely a newcomer to excel vba...only used couple of functions for my work...

    until my boss threw me with a text file with 100K lines...and the text-to-columns function won't be of any help...

    I have been searching for hours to find a vba solution for my problem to no avail...

    the format of the text file goes like this....


    Date : xx.xx.xxxx From : John doe To : Jane Doe, Chris Doe, etc.....
    Contents : blah blah blah...
    blah blah something...


    Date : xx.xx.xxxx From : John doe, Jane Doe To : Chris Doe, Jack, Amy, etc.....
    Contents : blah blah blah...
    blah blah something...

    the length of the sender and recipient almost always varies...and the length of the contents is also inconsistent...
    no ratio or length limits can be applied(as I need to pull out all of the contents in one cell...)
    moreover the contents itself can be separated by two or more lines(rows) on a random occasion and there may be the words
    "Date", "From", "To" within the content itself....

    what I am trying to do is convert the text file into an excel database form file...with the row headers Date / From / To / Contents...
    allowing no empty rows or cell entries(so that the database can be auto-filtered...)

    I think the only so-called delimiters(or separators) in the text file would be "Date :", "From :", "To :", "Contents :"

    But I can't seem to find any codes which fit my purpose...

    Any help would by so much appreciated....

    Thank you in advance....
    Last edited by antaga082; 11-12-2012 at 11:57 PM.

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: excel vba to separate single column entries into database format

    It will be good if you post a sample excel file here.

    To Attach a File:

    1. Click on Go Advanced
    2. In the frame Attach Files you will see the button Manage Attachments
    3. Click the button.
    4. A new window will open titled Manage Attachments - Excel Forum.
    5. Click the Browse... button to locate your file for uploading.
    6. This will open a new window File Upload.
    7. Once you have located the file to upload click the Open button. This window will close.
    8. You are now back in the Manage Attachments - Excel Forum window.
    9. Click the Upload button and wait until the file has uploaded.
    10. Close the window and then click Submit.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Registered User
    Join Date
    11-08-2012
    Location
    Seoul, Korea
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: excel vba to separate single column entries into database format

    thank you for your reply...

    here's an excerpt of the original text file...

    the length of each message is random...the only regularly occurring delimiters are as I previously mentioned...

    also, another regular occurrence is that there are two lines that distinguish each message...


    text sample.txt

  4. #4
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: excel vba to separate single column entries into database format

    Should the output be an excel file or a .txt file?

  5. #5
    Registered User
    Join Date
    11-08-2012
    Location
    Seoul, Korea
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: excel vba to separate single column entries into database format

    Quote Originally Posted by arlu1201 View Post
    Should the output be an excel file or a .txt file?
    The output file needs to be an excel file...preferably in a separate sheet within the same workbook...

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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