+ Reply to Thread
Results 1 to 2 of 2

Import text file problem

Hybrid View

  1. #1
    condotta@shaw.ca
    Guest

    Import text file problem

    Hello,

    I have this code which imports from a text file but the data is placed
    in the cells as a string until an {F2} and {enter} are preformed
    forcing the cell format to take over. Is there a neat way to do this on
    a large amount of cells and within my function?

    Set objFS = CreateObject("Scripting.FileSystemObject")
    Set objTextFile = objFS.OpenTextFile(sFileName, ForReading, False,
    0)

    With ImportRange

    ' Get to the starting position for the sequential import range
    in the text file
    If giEndLine <> 1 Then
    For I = 1 To giEndLine - 1
    objTextFile.SkipLine
    Next
    End If
    Application.Calculation = xlCalculationManual
    For Each vrow In .Cells.Rows
    WholeLine = objTextFile.ReadLine
    vrow.Value = Split(WholeLine, ";")
    Next
    Application.Calculation = xlCalculationAutomatic
    ' Set last line in range for global variable for next range.
    giEndLine = objTextFile.Line

    End With

    objTextFile.Close
    Set objTextFile = Nothing
    Set objFS = Nothing

    Regards,

    Stefano


  2. #2
    condotta@shaw.ca
    Guest

    Re: Import text file problem

    Sorry for the vague description. For those interested, I found the
    answer in another post. To get all imported text/string values back to
    their formats simply copy a blank cell to the imported values and
    pastespecial with xlpastevalues and xlpastespecialoperationadd. That
    does the trick.

    Regards,

    Stefano


+ 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