• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

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

Miteshkg

New Member
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
 
Hi !

You can use either InStr and Mid or Split VBA text functions
and Line Input statement …

And avoid wild cross posting
 
Thanks Marc L...I'm not too familiar with VBA scripting. Pls help me to write a code for this requirement. Would really appreciate your help on this.
 
Pls mind to upload a sample txt file.

Hi Deepak,
Pls find the attached Chat.txt file which has Group chat details and I need a 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.
 

Attachments

  • Chat.txt
    6.3 KB · Views: 3
Back
Top