+ Reply to Thread
Results 1 to 14 of 14

VBA Request - Import Data from Text File to Excel

  1. #1
    Forum Contributor spiwere's Avatar
    Join Date
    01-11-2013
    Location
    IN
    MS-Off Ver
    Excel 2007
    Posts
    410

    VBA Request - Import Data from Text File to Excel

    Hi,

    I need some help to import data from a text document to an excel file.

    Here’s the raw data (Text) file along with the requested output in the Excel sheet. The rules that need to be followed in the process of import are highlighted in green in the sample requested output file

    Look forward to your help!

    Thanks in advance,

    Spi
    Attached Files Attached Files

  2. #2
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: VBA Request - Import Data from Text File to Excel

    Spi,

    Give this a try:
    Please Login or Register  to view this content.
    Last edited by tigeravatar; 02-28-2013 at 12:34 PM.
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Forum Contributor spiwere's Avatar
    Join Date
    01-11-2013
    Location
    IN
    MS-Off Ver
    Excel 2007
    Posts
    410

    Re: VBA Request - Import Data from Text File to Excel

    Thanks Tigeravatar,

    Ooopss..it did work. There was some format issue in the text document I was trying to run. I saved the file again as text and it worked. I'll review the data now...

    Just one thing though is it possible to customize it a little so that it can loop through multiple text files in the folder?

    Best regards,
    Spi
    Last edited by spiwere; 02-28-2013 at 01:36 PM.

  4. #4
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: VBA Request - Import Data from Text File to Excel

    Updated code:
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor spiwere's Avatar
    Join Date
    01-11-2013
    Location
    IN
    MS-Off Ver
    Excel 2007
    Posts
    410

    Re: VBA Request - Import Data from Text File to Excel

    Absolutely fantastic! Thanks a ton sir. I'm closing the thread as "Solved". Its a perfect solution to my problem:-)

    By the way, may I just request for a small refinement only if it isn't too much of a problem. Is it possible to have the data from the Macro cleared prior to my run of the solution provided every time? If not, then I'll manage by deleting it manually.

    In any case, thank you for this awesome help and quick response!!!

    Ceers!!!

  6. #6
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: VBA Request - Import Data from Text File to Excel

    spiwere,

    Easy enough change:
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor spiwere's Avatar
    Join Date
    01-11-2013
    Location
    IN
    MS-Off Ver
    Excel 2007
    Posts
    410

    Re: VBA Request - Import Data from Text File to Excel

    Dear Tigeravatar,

    I'm running the solution now a days, it seems to be working fine.

    However, just one weird situation that I need your inputs on. The Macro doesn't seem to work on my Text documents from the system import unless I save them again in 2007 or above. These are in an older version 2003. Is that something that may be the cause for it? If yes, is there a way out to this that you can help me with please...

    Best,
    Spi

  8. #8
    Forum Contributor spiwere's Avatar
    Join Date
    01-11-2013
    Location
    IN
    MS-Off Ver
    Excel 2007
    Posts
    410

    Re: VBA Request - Import Data from Text File to Excel

    Dear Tigeravatar,

    Could you please look into for me. I'm unable to figure why this may be happening.

    Thank you in advance!

    Best,
    Spi

  9. #9
    Forum Contributor spiwere's Avatar
    Join Date
    01-11-2013
    Location
    IN
    MS-Off Ver
    Excel 2007
    Posts
    410

    Re: VBA Request - Import Data from Text File to Excel

    Dear Tigeravatar,

    My apologies to bother you! But despite of such a brilliant solution I'm stuck because of some version issues, to my guess...

    Could you please advise, as the solution doesn't seem to run until I copy paste the data from the imported versions to note pad on 2007 or above, where it works. Hope I'm not missing something here...

    Look forward to your inputs...

    Best regards,
    Spi

  10. #10
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: VBA Request - Import Data from Text File to Excel

    Spi,

    Unfortunately, I have no idea what is causing that. I have asked for help on this and hopefully someone will be able to assist you.

  11. #11
    Forum Contributor spiwere's Avatar
    Join Date
    01-11-2013
    Location
    IN
    MS-Off Ver
    Excel 2007
    Posts
    410

    Re: VBA Request - Import Data from Text File to Excel

    Thanks a lot!

    I'm wondering too as to why this may be happening. I'll lookout for help and assistance, as you suggested.

    Please do provide some inputs if you get any....

    Best regards,
    Spi

  12. #12
    Forum Contributor spiwere's Avatar
    Join Date
    01-11-2013
    Location
    IN
    MS-Off Ver
    Excel 2007
    Posts
    410

    Re: VBA Request - Import Data from Text File to Excel

    Need some assitance on this bit. Could someone please look int it. The challange I'm facing on the brilliant solution already provided is mentioned from post 7 onwards...

    Look forward to some help!

    Thanks,
    Spi

  13. #13
    Forum Contributor spiwere's Avatar
    Join Date
    01-11-2013
    Location
    IN
    MS-Off Ver
    Excel 2007
    Posts
    410

    Re: VBA Request - Import Data from Text File to Excel

    I await inputs on this request.

    Please advise.

    Spi

  14. #14
    Forum Contributor spiwere's Avatar
    Join Date
    01-11-2013
    Location
    IN
    MS-Off Ver
    Excel 2007
    Posts
    410

    Re: VBA Request - Import Data from Text File to Excel

    Could someone shed some light on this small problem.

    My problem is that nothing is happening when I run the Macro.

    Please Login or Register  to view this content.
    Thank you in advance!

    Spi
    Last edited by spiwere; 03-12-2013 at 01:48 AM.

+ 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