View Single Post
  #2   Report Post  
Dave Peterson
 
Posts: n/a
Default

I think I'd do a little preprocessing on the file.

Option Explicit
Sub testme()

Dim iFileName As Variant
Dim oFileName As String

Dim iFileNum As Long
Dim oFileNum As Long

Dim myLine As String
Dim myPrevLine As String

iFileName = Application.GetOpenFilename("Text Files, *.txt")

If iFileName = False Then
Exit Sub 'user hit cancel
End If

oFileName = Left(iFileName, Len(iFileName) - 4) & ".OUT"

iFileNum = FreeFile
Close iFileNum
Open iFileName For Input As iFileNum

oFileNum = FreeFile
Close oFileNum
Open oFileName For Output As oFileNum

Do While Not EOF(iFileNum)
Line Input #iFileNum, myLine
If myPrevLine = "" Then
myPrevLine = myLine
Else
If Left(myLine, 6) Like "##?###" Then
Print #oFileNum, myPrevLine
myPrevLine = myLine
Else
myPrevLine = myPrevLine & " " & myLine
End If
End If
Loop

'write the last output row
Print #oFileNum, myPrevLine

Close #iFileNum
Close #oFileNum
End Sub


This creates a .OUT file that can be imported the way you wanted.

Another option would be to import the file the way excel does it, then
manipulate the data within excel--kind of a 6 of one/half dozen of the other.

Topje wrote:

I want to import a .txt into Excel. One item is a string which contains enters.

example:

00.001;"text wich contains an enter
and continues on the next row one
or more times";
00.002;"text without enters is imported correctly";

I want excel to put the entire string into one cell.


--

Dave Peterson