+ Reply to Thread
Results 1 to 3 of 3

Transfer text file data to spreadsheet via vba

  1. #1
    Forum Contributor
    Join Date
    08-05-2009
    Location
    Colorado Springs, CO
    MS-Off Ver
    Office 365
    Posts
    160

    Transfer text file data to spreadsheet via vba

    I am trying to selectively read a text file into a spreadsheet. Up until now I just copy and paste it in. This is fairly easy, but I'd like to be able to just load the parts of the file I want and have it load only the parts I want. The text file has a lot of extraneous information (180,000 lines) and I need less than 100. I have written some code to read the file and capture only the lines I want. Having done that, I want to transfer parts of the captured data into a range in a spreadsheet. Here's the code I have so far:

    Please Login or Register  to view this content.
    This is what the print statement produces:

    Please Login or Register  to view this content.
    So far, so good. I just want the 3rd and 5th columns of data to go on the spreadsheet. I know I can get this done by brute force, but it seems like there must be a simple way to transfer the data to an array and plug it into the spreadsheet, and I'd like to know what that might be without have to reinvent the wheel.

    Thanks.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Transfer text file data to spreadsheet via vba

    Try something like this (not tested)...

    Please Login or Register  to view this content.
    Last edited by AlphaFrog; 09-04-2016 at 06:47 PM.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Contributor
    Join Date
    08-05-2009
    Location
    Colorado Springs, CO
    MS-Off Ver
    Office 365
    Posts
    160

    Re: Transfer text file data to spreadsheet via vba

    Worked great. Thanks.

+ 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. VB to use data from spreadsheet and input box to create new folder and text file
    By cmccabe in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-19-2015, 05:40 PM
  2. [SOLVED] extracting data from text file and put it into spreadsheet
    By El Conquistador in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-27-2013, 08:27 AM
  3. Replies: 3
    Last Post: 01-09-2012, 09:04 PM
  4. Excel to text file transfer of data.
    By ramanan256 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-10-2010, 07:50 PM
  5. transfer excel file to text file format
    By tllcll in forum Excel General
    Replies: 1
    Last Post: 07-17-2006, 07:55 AM
  6. [SOLVED] Transfer text to another spreadsheet
    By Susan in forum Excel - New Users/Basics
    Replies: 12
    Last Post: 03-23-2006, 06:06 PM
  7. Creating a text file and printing excel spreadsheet data onto it
    By Brett Smith in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-22-2005, 12:25 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