using workbooks.OpenText with a set number of lines in Excel VBA

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JonathanS
    New Member
    • Jan 2008
    • 37

    using workbooks.OpenText with a set number of lines in Excel VBA

    Hi- I'm using Excel 2000 and attempting to import only the first n lines of a text file. The Wizard allows the user to select the first line, but is there a way to specify the last line of text desired (so if I only want the beginning 1000 lines and ditch the rest)?

    There doesn't seem to be an argument for workbooks.OpenT ext to specify this information. Currently I am reading in the entire file and clearing out the part I don't need via VBA, but this is extremely memory intensive.

    Thanks!
  • Dököll
    Recognized Expert Top Contributor
    • Nov 2006
    • 2379

    #2
    Hey there JonathanS!

    I don't mean to be particular but I saw VBA and thought Access forum, but do yell murder if you wanted this in VB:-). Just wanted to push it along for ya for added hits...

    In a bit Jonathans, enjoy a good week-end.

    Dököll

    Comment

    • ADezii
      Recognized Expert Expert
      • Apr 2006
      • 8834

      #3
      OpenText() does not have an Argument in which you can specify the Ending Row on a Text Import. If worse comes to worse, why not simply import the entire Text File then clear the unwanted data as in:
      [CODE=text]
      'Clear data in specified Range
      Worksheets("She et1").Range("A1 001:L2000").Cle arContents[/CODE]

      Comment

      Working...