Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    May 2005
    Location
    Wilcox, Saskatchewan
    Posts
    171
    Thanks
    0
    Thanked 0 Times in 0 Posts

    ASCII Change formatting (Excel 03)

    I received a text file which has been formated in a fashion that is unuseable

    i was wondering if there is an excel function that can reformat the data basically the format now is 8 rows which have data that should be on one line
    is there a easy ay to fix this?

    there is about 10000 rows in the format descibed that should be 10000/8



    -999.25000 -999.25000 -999.25000 -999.25000 -999.25000 -999.25000
    -999.25000 -999.25000 -999.25000 -999.25000 -999.25000 -999.25000
    -999.25000 -999.25000 -999.25000 -999.25000 -999.25000 -999.25000
    -999.25000 -999.25000 -999.25000 -999.25000 -999.25000 -999.25000
    -999.25000 -999.25000 -999.25000 -999.25000 -999.25000 -999.25000
    -999.25000 -999.25000 -999.25000 -999.25000 -999.25000 -999.25000
    -999.25
    2185.2634

    should be'

    all on one row

    any solutions?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: ASCII Change formatting (Excel 03)

    You could use a macro like this to import the file into Excel. Modify the path/file name in the constant at the beginning.

    Sub Import8()
    ' Modify as needed
    Const strFile = "C:Test.txt"
    Dim f As Integer
    Dim strLine As String
    Dim strVal As String
    Dim i As Long
    Dim n As Long

    On Error GoTo ErrHandler

    f = FreeFile
    Open strFile For Input As #f
    Do While Not EOF(f)
    strVal = ""
    For i = 1 To 8
    Line Input #f, strLine
    strVal = strVal & " " & strLine
    Next i
    n = n + 1
    Cells(n, 1) = strVal
    Loop

    ExitHandler:
    On Error Resume Next
    Close #f
    Exit Sub

    ErrHandler:
    MsgBox Err.Description, vbExclamation
    Resume ExitHandler
    End Sub

  3. #3
    2 Star Lounger
    Join Date
    May 2005
    Location
    Wilcox, Saskatchewan
    Posts
    171
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: ASCII Change formatting (Excel 03)

    Thanks Hans for your time this is very helpful

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •