+ Reply to Thread
Results 1 to 13 of 13

Import dat. file

Hybrid View

tuggers Import dat. file 02-21-2006, 07:34 AM
Guest RE: Import dat. file 02-21-2006, 09:00 AM
Guest Re: Import dat. file 02-21-2006, 09:35 AM
Guest Re: Import dat. file 02-21-2006, 11:20 AM
tuggers Thanks for the interest guys... 02-22-2006, 07:07 AM
Guest Re: Import dat. file 02-22-2006, 09:10 AM
Guest Re: Import dat. file 02-23-2006, 07:35 AM
tuggers WOW!! That looks... 02-23-2006, 11:00 AM
Guest Re: Import dat. file 02-23-2006, 09:20 PM
tuggers i tried using the code you... 02-24-2006, 11:15 AM
tuggers I have found the following... 02-24-2006, 11:29 AM
Guest Re: Import dat. file 02-24-2006, 09:45 PM
tuggers That seems to work!! I... 02-25-2006, 03:33 AM
  1. #1
    kounoike
    Guest

    Re: Import dat. file

    Sorry, I've forgot to add one if statement.

    "kounoike" <kounoike@nowherembh.nifty.com> wrote in message
    news:eMu1M$6NGHA.3272@tk2msftngp13.phx.gbl...
    > Hi
    >
    > i don't know whether this would work in your case, but give it try.
    >
    > Sub MultiImporttest()
    > Dim flname
    > Dim filename
    > Dim FileNum As Integer
    > Dim Counter As Long, maxrow As Long
    > Dim WorkResult As String
    > Dim ws As Worksheet
    > On Error GoTo ErrorCheck
    > maxrow = Cells.Rows.Count
    > 'Ask for the name of the file.
    > filename = Application.GetOpenFilename(FileFilter:="all file (*.*),*.*",
    > MultiSelect:=True)
    > 'Check for no entry.
    > If VarType(filename) = vbBoolean Then
    > Exit Sub
    > End If
    >
    > Application.ScreenUpdating = False
    > Application.EnableEvents = False
    >
    > Counter = Cells(Cells.Rows.Count, "a").End(xlUp).Row


    '===>>add a if statement below here
    If Cells(Counter, "a") <> "" Then
    Counter = Counter + 1
    End If
    '===>>end

    > For Each flname In filename
    > FileNum = FreeFile()
    > Open flname For Input As #FileNum


    keizi


  2. #2
    Registered User
    Join Date
    11-22-2005
    Posts
    8
    WOW!!

    That looks fantastic!!

    The only trouble is im a bit of a vba novice!

    The required dat. files are stored in a folder called 'Tricoder'
    and the file is stored on T: drive (shared drive at my place of work)
    Can you please show me where i would place this information.

    Again, many thanks for the help

  3. #3
    kounoike
    Guest

    Re: Import dat. file

    Hi

    just run the macro, then a dialog for opening files appears. change to the folder
    where files you want to import are, and select all files you want to import
    - same way as you do when you use explore - and press OK button.
    if you miss to select some files, run again the macro and select missing files
    with worksheet where data already are selected, then it will add the data into
    that worksheet.
    That's all. But i'm not sure this will end up with what you want to get.

    keizi

    "tuggers" <tuggers.23otuq_1140707404.3643@excelforum-nospam.com> wrote in message
    news:tuggers.23otuq_1140707404.3643@excelforum-nospam.com...
    >
    > WOW!!
    >
    > That looks fantastic!!
    >
    > The only trouble is im a bit of a vba novice!
    >
    > The required dat. files are stored in a folder called 'Tricoder'
    > and the file is stored on T: drive (shared drive at my place of work)
    > Can you please show me where i would place this information.
    >
    > Again, many thanks for the help
    >
    >
    > --
    > tuggers
    > ------------------------------------------------------------------------
    > tuggers's Profile:

    http://www.excelforum.com/member.php...o&userid=29000
    > View this thread: http://www.excelforum.com/showthread...hreadid=514838
    >



  4. #4
    Registered User
    Join Date
    11-22-2005
    Posts
    8
    i tried using the code you supplied but its throwing up a syntax error for the following part:

    filename = Application.GetOpenFilename(FileFilter:="all file (*.*),*.*",
    MultiSelect:=True)

    Any ideas of what to change to stop this??

  5. #5
    Registered User
    Join Date
    11-22-2005
    Posts
    8
    I have found the following information for importing files into a single worksheet.

    The trouble is i dont really understand what it all means!!

    Could somebody please fill in the necessary changes for this to work??

    Many, many thanks

  6. #6
    kounoike
    Guest

    Re: Import dat. file

    Hi

    i wrote the code in one line. but when i pasted the code, my mailer inserted
    the code new line automatically that caused syntax error. i think there is
    more places which cause syntax error.
    i'll put the code changed which would not cause syntax error when you copy.
    But in case that there are syntax error again, please let me know.

    Sub MultiImporttest()
    Dim flname
    Dim filename
    Dim FileNum As Integer
    Dim Counter As Long, maxrow As Long
    Dim WorkResult As String
    Dim ws As Worksheet

    On Error GoTo ErrorCheck
    maxrow = Cells.Rows.Count
    filename = Application.GetOpenFilename _
    (FileFilter:="all file(*.*),*.*", MultiSelect:=True)
    If VarType(filename) = vbBoolean Then
    Exit Sub
    End If

    Application.ScreenUpdating = False
    Application.EnableEvents = False

    Counter = Cells(Cells.Rows.Count, "a").End(xlUp).Row
    If Cells(Counter, "a") <> "" Then
    Counter = Counter + 1
    End If

    For Each flname In filename
    FileNum = FreeFile()
    Open flname For Input As #FileNum
    Do While Seek(FileNum) <= LOF(FileNum)
    Application.StatusBar = "Importing Row " & _
    Counter & " of text file " & flname
    Line Input #FileNum, WorkResult
    Set ws = Nothing
    Set ws = ActiveSheet
    ws.Select
    Cells(Counter, 1) = WorkResult
    If WorkResult <> "" Then
    Application.DisplayAlerts = False
    Cells(Counter, 1).TextToColumns _
    Destination:=Cells(Counter, 1), _
    DataType:=xlDelimited, _
    TextQualifier:=xlDoubleQuote, _
    ConsecutiveDelimiter:=False, _
    Tab:=False, Semicolon:=False, _
    Comma:=True, Space:=False, _
    Other:=False
    End If
    Counter = Counter + 1
    If Counter > maxrow Then
    MsgBox "data have over max rows: " & maxrow
    Exit Sub
    End If
    Loop
    Close
    Next

    Application.StatusBar = False
    Application.EnableEvents = True
    Application.ScreenUpdating = True
    Exit Sub
    ErrorCheck:
    Application.StatusBar = False
    Application.EnableEvents = True
    Application.ScreenUpdating = True
    MsgBox "An error occured in the code."
    End Sub

    keizi

    "tuggers" <tuggers.23qoqz_1140794109.2564@excelforum-nospam.com> wrote in message
    news:tuggers.23qoqz_1140794109.2564@excelforum-nospam.com...
    >
    > i tried using the code you supplied but its throwing up a syntax error
    > for the following part:
    >
    > filename = Application.GetOpenFilename(FileFilter:="all file
    > (*.*),*.*",
    > MultiSelect:=True)
    >
    > Any ideas of what to change to stop this??
    >
    >
    > --
    > tuggers
    > ------------------------------------------------------------------------
    > tuggers's Profile:

    http://www.excelforum.com/member.php...o&userid=29000
    > View this thread: http://www.excelforum.com/showthread...hreadid=514838
    >



  7. #7
    Registered User
    Join Date
    11-22-2005
    Posts
    8
    That seems to work!!

    I cant thank you enough..........

    So much appreciated

+ 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