+ Reply to Thread
Results 1 to 3 of 3

Importing

  1. #1
    Dan
    Guest

    Importing

    I want to import a file into excel but I want to limit the number of lines
    that is imported. For example the file may be 150 lines but I only want the
    first 35. I want to automate this task.

    Also I want the to import the data at a specific line in excel - not A1,
    somewhere around A10.

    Thanks

  2. #2
    Dave Peterson
    Guest

    Re: Importing

    I'd just import it to a new workbook, then copy what I want and paste to where I
    want it. Then close the new workbook.

    Option Explicit
    Sub testme01()

    Dim DestCell As Range
    Dim TextWks As Worksheet

    Set DestCell = ActiveSheet.Range("a10")

    Workbooks.OpenText Filename:="C:\yourfilenamehere.txt", _
    StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
    ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, _
    Comma:=False, Space:=False, Other:=False, FieldInfo:=Array(1, 1)

    Set TextWks = ActiveSheet

    TextWks.Range("1:35").Copy _
    Destination:=DestCell

    TextWks.Parent.Close savechanges:=False

    End Sub

    Record a macro when you do the importing and replace my Opentext line with
    yours.


    Dan wrote:
    >
    > I want to import a file into excel but I want to limit the number of lines
    > that is imported. For example the file may be 150 lines but I only want the
    > first 35. I want to automate this task.
    >
    > Also I want the to import the data at a specific line in excel - not A1,
    > somewhere around A10.
    >
    > Thanks


    --

    Dave Peterson

  3. #3
    Dan
    Guest

    Re: Importing

    I'll try this out. Thanks

    "Dave Peterson" wrote:

    > I'd just import it to a new workbook, then copy what I want and paste to where I
    > want it. Then close the new workbook.
    >
    > Option Explicit
    > Sub testme01()
    >
    > Dim DestCell As Range
    > Dim TextWks As Worksheet
    >
    > Set DestCell = ActiveSheet.Range("a10")
    >
    > Workbooks.OpenText Filename:="C:\yourfilenamehere.txt", _
    > StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
    > ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, _
    > Comma:=False, Space:=False, Other:=False, FieldInfo:=Array(1, 1)
    >
    > Set TextWks = ActiveSheet
    >
    > TextWks.Range("1:35").Copy _
    > Destination:=DestCell
    >
    > TextWks.Parent.Close savechanges:=False
    >
    > End Sub
    >
    > Record a macro when you do the importing and replace my Opentext line with
    > yours.
    >
    >
    > Dan wrote:
    > >
    > > I want to import a file into excel but I want to limit the number of lines
    > > that is imported. For example the file may be 150 lines but I only want the
    > > first 35. I want to automate this task.
    > >
    > > Also I want the to import the data at a specific line in excel - not A1,
    > > somewhere around A10.
    > >
    > > Thanks

    >
    > --
    >
    > Dave Peterson
    >


+ 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