+ Reply to Thread
Results 1 to 22 of 22

VBA Code to copy specific contents from 2 text files to separate excel columns

  1. #1
    Registered User
    Join Date
    09-29-2015
    Location
    India
    MS-Off Ver
    2013
    Posts
    16

    Lightbulb VBA Code to copy specific contents from 2 text files to separate excel columns

    HI all,

    I've a specific requirement where in there will be 2 text files which will have information like normal text plus date and time stamp of communication. Basically, the VB code should read each line of text file and copy date and time to one column in excel and other text contents to second column. all text contents are available only after date and time format like [‎12/‎30/‎2015 10:01 PM] Srinivasan Varadaraj: Dear All, We have .....................blablabla....
    So what I want is copy ‎12/‎30/‎2015 10:01 PM in Column A and everything after ":" should be in Column B..

    Like this, Code should read through end of text file and where ever the time stamp is written, copy to Excel Column A and remaining text after ":" to Column B.

    Let me know if I've made my self clear to explain my requirement. I need to submit a project by EOD tomorrow. Any quick help is highly appreciated.

    Please Help

  2. #2
    Registered User
    Join Date
    09-29-2015
    Location
    India
    MS-Off Ver
    2013
    Posts
    16

    Re: VBA Code to copy specific contents from 2 text files to separate excel columns

    Need help guys....

  3. #3
    Valued Forum Contributor
    Join Date
    02-02-2016
    Location
    Indonesia
    MS-Off Ver
    Office 365
    Posts
    1,004

    Re: VBA Code to copy specific contents from 2 text files to separate excel columns

    Try this:
    Open the the text file in Excel then run the macro.
    (Backup your file first)
    Please Login or Register  to view this content.

  4. #4
    Valued Forum Contributor
    Join Date
    02-02-2016
    Location
    Indonesia
    MS-Off Ver
    Office 365
    Posts
    1,004

    Re: VBA Code to copy specific contents from 2 text files to separate excel columns

    Just to be clear, this is in one row, right?
    [‎12/‎30/‎2015 10:01 PM] Srinivasan Varadaraj: Dear All, We have bla bla

  5. #5
    Registered User
    Join Date
    09-29-2015
    Location
    India
    MS-Off Ver
    2013
    Posts
    16

    Re: VBA Code to copy specific contents from 2 text files to separate excel columns

    No date and contents are on 2 different row in text file...

    I've a specific requirement where in I need to import text file which is non-delimited and contents should be copied to Excel in different columns...

    Text file contents is as below.

    Need VBA code to copy this in Excel different columns like

    DAte and time should go to Column A
    Name of the person before : should go to Column B
    and contents between : and new date start [ should go to Column C

    Please reach me on +91 98197 23533 or [email protected]

    [‎12/‎30/‎2015 10:01 PM] Srinivasan Varadaraj:
    Dear All,
    We have report of “TFS application tier connection shows packet drops”. We have initiated a P2 INC3515622 & opened the P2 Bridge. I will be the incident manager.
    The SMT team is contacting resources to join the P1/P2 incident bridge.
    Business Impact : 230 users impacted.
    Call In: 1-855-488-1100
    Participant Code: 20482240
    [‎12/‎30/‎2015 10:10 PM] Kamlesh Chaudhari:
    we created ticket with GCX ticket no is 1872
    [‎12/‎30/‎2015 10:22 PM] Srinivasan Varadaraj:
    Kamlesh from CMC Joined the call
    Anand from L2 Network joined the call
    [‎12/‎30/‎2015 10:23 PM] Srinivasan Varadaraj:
    Team is currently waiting for an update from the GCX vendor team.
    [‎12/‎30/‎2015 10:47 PM] Srinivasan Varadaraj:
    Dear All,


    L2 Network team joined the call and working.
    Ticket is raised with the GCX vendor, ticket #: 1872.
    Further troubleshooting is in progress.
    [‎12/‎30/‎2015 11:14 PM] Srinivasan Varadaraj:
    Dear All,
    L2 network team has provided technical information which was requested by GCX.
    GCX vendor is working on the issue.
    At the moment the issue is reported only for TFS application.
    No ETR provided by vendor GCX.
    [‎12/‎30/‎2015 11:25 PM] Kamlesh Chaudhari:
    L2 - Network tem is providing information about VPLS to GCX
    [‎12/‎30/‎2015 11:58 PM] Srinivasan Varadaraj:
    Dear All,
    L2 Network team confirmed that the issue is only specific to Pune VPLS.
    Vendor GCX is working on the issue.
    At present no ETR provided by vendor GCX.
    [‎12/‎31/‎2015 12:29 AM] Srinivasan Varadaraj:
    Dear All,
    GCX Vendor, L2 network team and Pune It support team are working on the issue.
    No ETR provided.
    [‎12/‎31/‎2015 12:56 AM] Anand Kumar:
    With Sachin we verified the connectivity like this
    SWIDIS01 ge-1/0/0---------------LAN0_0 Riverbed Wan0_0--------------VPLS device
    Asked him to replace the cable between Riverbed and VPLS device
    Riverbed Wan0_0--------------VPLS device
    [‎12/‎31/‎2015 12:59 AM] Srinivasan Varadaraj:

  6. #6
    Registered User
    Join Date
    09-29-2015
    Location
    India
    MS-Off Ver
    2013
    Posts
    16

    Re: VBA Code to copy specific contents from 2 text files to separate excel columns

    No Date and contents are in 2 different rows in text file.

    I've a specific requirement where in I need to import text file which is non-delimited and contents should be copied to Excel in different columns...

    Text file contents is as below.

    Need VBA code to copy this in Excel different columns like

    DAte and time should go to Column A
    Name of the person before : should go to Column B
    and contents between : and new date start [ should go to Column C

    Please reach me on +91 98197 23533 or [email protected]

    [‎12/‎30/‎2015 10:01 PM] Srinivasan Varadaraj:
    Dear All,
    We have report of “TFS application tier connection shows packet drops”. We have initiated a P2 INC3515622 & opened the P2 Bridge. I will be the incident manager.
    The SMT team is contacting resources to join the P1/P2 incident bridge.
    Business Impact : 230 users impacted.
    Call In: 1-855-488-1100
    Participant Code: 20482240
    [‎12/‎30/‎2015 10:10 PM] Kamlesh Chaudhari:
    we created ticket with GCX ticket no is 1872
    [‎12/‎30/‎2015 10:22 PM] Srinivasan Varadaraj:
    Kamlesh from CMC Joined the call
    Anand from L2 Network joined the call
    [‎12/‎30/‎2015 10:23 PM] Srinivasan Varadaraj:
    Team is currently waiting for an update from the GCX vendor team.
    [‎12/‎30/‎2015 10:47 PM] Srinivasan Varadaraj:
    Dear All,


    L2 Network team joined the call and working.
    Ticket is raised with the GCX vendor, ticket #: 1872.
    Further troubleshooting is in progress.
    [‎12/‎30/‎2015 11:14 PM] Srinivasan Varadaraj:
    Dear All,
    L2 network team has provided technical information which was requested by GCX.
    GCX vendor is working on the issue.
    At the moment the issue is reported only for TFS application.
    No ETR provided by vendor GCX.
    [‎12/‎30/‎2015 11:25 PM] Kamlesh Chaudhari:
    L2 - Network tem is providing information about VPLS to GCX
    [‎12/‎30/‎2015 11:58 PM] Srinivasan Varadaraj:
    Dear All,
    L2 Network team confirmed that the issue is only specific to Pune VPLS.
    Vendor GCX is working on the issue.
    At present no ETR provided by vendor GCX.
    [‎12/‎31/‎2015 12:29 AM] Srinivasan Varadaraj:
    Dear All,
    GCX Vendor, L2 network team and Pune It support team are working on the issue.
    No ETR provided.
    [‎12/‎31/‎2015 12:56 AM] Anand Kumar:
    With Sachin we verified the connectivity like this
    SWIDIS01 ge-1/0/0---------------LAN0_0 Riverbed Wan0_0--------------VPLS device
    Asked him to replace the cable between Riverbed and VPLS device
    Riverbed Wan0_0--------------VPLS device
    [‎12/‎31/‎2015 12:59 AM] Srinivasan Varadaraj:

  7. #7
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: VBA Code to copy specific contents from 2 text files to separate excel columns

    http://forum.chandoo.org/threads/vba...columns.27254/

    If attached does not work, just ignore.

    Workbook, original txt file attached.
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    09-29-2015
    Location
    India
    MS-Off Ver
    2013
    Posts
    16

    Re: VBA Code to copy specific contents from 2 text files to separate excel columns

    Wow....Amazing jindon...Many thanks...this is what I was looking for....
    1. Can we merge the column C with all the comments in one cell
    2. Is it possible to add additional line (probably with Orange color) after every 30 mins of incident timeline mentioned in column A

  9. #9
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: VBA Code to copy specific contents from 2 text files to separate excel columns

    Post a workbook with your desired result.

  10. #10
    Registered User
    Join Date
    09-29-2015
    Location
    India
    MS-Off Ver
    2013
    Posts
    16

    Re: VBA Code to copy specific contents from 2 text files to separate excel columns

    Basically, team members will copy the group chat details regarding incident in one file and service now ticket updates in second file. Both word files are attached for your reference. we will ask the team to copy the contents from both Chat window and ticketing tool to notepad. Thats not an issue.

    So, once they copy the group chat details in one notepad and run the macro,
    date and time should go to Column A
    Name of the person should go to Column B
    Contents of the chat should go to Column C (this is what we have already achieved)

    Similarly, they will copy the contents of service now ticket tool updates to notepad 2 and run the macro and
    date and time should go to Column A
    Name of the person should go to Column B
    Contents of the chat should go to Column C (this should be append in the file)

    after which entire sheet should be formatted as table and all cells should be sort with incident timeline chronological order and after every 30 mins...a orange line should be added

    Required output is also attached as Excel sheet in which you can ignore the column A.

    but rest of the things should be similar which is a manual process as of now but want to automate the same.
    Last edited by Miteshkg; 02-10-2016 at 08:04 AM.

  11. #11
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: VBA Code to copy specific contents from 2 text files to separate excel columns

    You have attached Word doc, not Text file.

  12. #12
    Registered User
    Join Date
    09-29-2015
    Location
    India
    MS-Off Ver
    2013
    Posts
    16

    Re: VBA Code to copy specific contents from 2 text files to separate excel columns

    Please find the text file attached.
    Attached Files Attached Files

  13. #13
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: VBA Code to copy specific contents from 2 text files to separate excel columns

    I'm confusing.

    Is there any relation between your desire result and those 2 text files?

    What is interval? from what time?
    What is Process column?

  14. #14
    Registered User
    Join Date
    09-29-2015
    Location
    India
    MS-Off Ver
    2013
    Posts
    16

    Re: VBA Code to copy specific contents from 2 text files to separate excel columns

    Sorry for the confusion.

    Let me describe in another way.
    Team member has group chat details and those will be copied to text file. Now, we need that text file import in excel and all the details should go to respective columns like, Date and Time in Column A, Name in Column B and Contents of chat between 2 date/time to Column C. Now, this part is already completed with your previous help.

    Those 2 attached text files are the Incident group chat and ticket updates. Team members copy those details in 2 different text file and then manually copying the details in excel sheet. We want to automate this and with your earlier code, now I will be able to achieve automation in first text file - "P2 Incident Chat" which has group chat details.

    For second file - "P2 Incident service now updates" I need similar functionality that Date and Time in Column A, Name in Column B and Contents between 2 date/time to Column C.

    After which,
    - Can we merge the contents of column C in one cell? (as mentioned in my desired excel sheet)
    - Once the date and time column is sort in a chronological order, right from first row time, every 30 mins, we need to add blank orange line.

    Please unblock the VB project so that I can do the further modification as per my requirement. Thanks in advance.

    Really appreciate your follow up and great help on this requirement.
    Last edited by Miteshkg; 02-10-2016 at 11:57 AM. Reason: more info

  15. #15
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: VBA Code to copy specific contents from 2 text files to separate excel columns

    Try
    Please Login or Register  to view this content.

  16. #16
    Registered User
    Join Date
    09-29-2015
    Location
    India
    MS-Off Ver
    2013
    Posts
    16

    Re: VBA Code to copy specific contents from 2 text files to separate excel columns

    Hi jindon,

    Thanks for the code...The code for IncidentChat is working absolutely fine as per my requirement where in I've used "P2 Incident Chat.txt" file as my text file for import.

    However, second code IncidentUpdate is not working and giving error as
    Run-time error '1004':
    Sort method of Range class failed.


    I'm using P2 Incident service now updates.txt file as import file for 2nd code.

    On debugging, it is prompting to .Sort .Cells(1), 1 line...

    Please help to overcome this issue.

    Rest of the things are as per my requirement.

    Question: - I would create 2 buttons to call both the macros. Would IncidentUpdate code will append the contents to existing excel sheet or do I need to run the code on separate excel sheet?

  17. #17
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: VBA Code to copy specific contents from 2 text files to separate excel columns

    Working fine for me
    Attached Files Attached Files

  18. #18
    Registered User
    Join Date
    09-29-2015
    Location
    India
    MS-Off Ver
    2013
    Posts
    16

    Re: VBA Code to copy specific contents from 2 text files to separate excel columns

    Thanks...I guess the Incident update text file was modified by trimming the leading space and remove empty lines. I guess that will work.

    Many Thanks to you for resolving the issue in just one day....u really made my day....appreciate your valuable time and prompt response.

    Cheers!!

  19. #19
    Registered User
    Join Date
    09-29-2015
    Location
    India
    MS-Off Ver
    2013
    Posts
    16

    Re: VBA Code to copy specific contents from 2 text files to separate excel columns

    Issue resolved.
    Last edited by Miteshkg; 02-22-2016 at 03:45 AM.

  20. #20
    Registered User
    Join Date
    09-29-2015
    Location
    India
    MS-Off Ver
    2013
    Posts
    16

    Re: VBA Code to copy specific contents from 2 text files to separate excel columns

    Issue resolved.
    Last edited by Miteshkg; 02-22-2016 at 03:46 AM.

  21. #21
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: VBA Code to copy specific contents from 2 text files to separate excel columns

    Miteshkg

    You can not ask multiple questions in one thread, so open a new thread for your new question.
    Suggest you to attach source txt file and a workbook with desired result in a new thread.

  22. #22
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: VBA Code to copy specific contents from 2 text files to separate excel columns

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

+ 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. Macro to separate data based on contents of a column to 2 new excel files
    By beautify5 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-18-2015, 11:19 AM
  2. Replies: 0
    Last Post: 06-16-2015, 08:52 AM
  3. [SOLVED] code to clear all contents in columns with specific text in row 2
    By xcelnovice101 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-30-2014, 08:58 AM
  4. Export Columns to separate Text files
    By murtly in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-31-2014, 08:25 AM
  5. VBA Code to open text files and copy information over to an excel sheet
    By kenadams378 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-03-2012, 12:18 PM
  6. Exporting large number of columns along with 1 fixed column into separate text files
    By akshaynr in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-13-2010, 11:08 AM
  7. Import 2 text files into 2 separate columns?
    By tcurrier in forum Excel General
    Replies: 3
    Last Post: 02-11-2006, 03:13 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