+ Reply to Thread
Results 1 to 8 of 8

Importing selection of txt?

  1. #1
    Registered User
    Join Date
    06-20-2011
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2003
    Posts
    7

    Unhappy Importing selection of txt?

    I have a VBA code importing a txt file and formating it, but I wish to modify the code to only import the latest 50 rows (when new data is added the oldest is removed). I picture a offset function might do the selection before importing, but not sure how to go about this?

    this is my code today:

    Please Login or Register  to view this content.
    Apreciate any help I can get

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644
    Why not import the entire file to a temporary worksheet then copy the last 50 rows to their destination?
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    06-20-2011
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Importing selection of txt?

    I want it all automated, and I dont know how to do this

    The code I use do open the file temorary, but need to find a code to select the last 50 rows.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644
    I wasn't suggesting doing anything manually.

    Everything I suggested can be done with code, and you've already got the code for the first part, importing the whole file.

    You can't treat the text file like an Excel worksheet so can't use anything like Offset/Resize.

    However if you import the entire text file to a worksheet you can use things like that.

  5. #5
    Registered User
    Join Date
    06-20-2011
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Importing selection of txt?

    IC! make sense! Do you know where I can find a tutorial or simular code (code for importing the text file to worksheet and select the latest 50 rows, the copy in my excel sheet?

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644
    What does the code you posted do?

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Importing selection of txt?

    In the current file you would want the rows 755 to 804?

    Where should they go?
    Please Login or Register  to view this content.
    Last edited by Norie; 12-11-2012 at 09:40 AM.

  8. #8
    Registered User
    Join Date
    06-20-2011
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Importing selection of txt?

    Thiw works perfectly! thank you.

+ 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