View Single Post
  #6  
Old 06-12-2009, 03:16 PM
martindwilson's Avatar
martindwilson martindwilson is offline
Forum Guru
 
Join Date: 23 Jun 2007
Location: London,England
MS Office Version:office 97 ,2003 ,2007
Posts: 6,006
martindwilson Has a higher level of understanding martindwilson Has a higher level of understanding martindwilson Has a higher level of understanding martindwilson Has a higher level of understanding martindwilson Has a higher level of understanding martindwilson Has a higher level of understanding martindwilson Has a higher level of understanding
Re: Converting LARGE text files to excel

ok i cobbled together this from above code
it just uses the text to columns and autofit. i couldnt get beyond18 sheets without running out of memory tho (with either code)
martin rice might have a better solution though
Code:
Sub Test()
Application.ScreenUpdating = False
Open "C:\Documents and Settings\Martin Wilson\Desktop\test[1].txt" For Input As #1
Do While Not EOF(1)
    Counter = Counter + 1
    Line Input #1, FileLine
    ActiveSheet.Cells(Counter, 1) = FileLine
    If Counter = 65000 Then
      Columns("A:A").Select
    Selection.TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _
        TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=True, _
        Semicolon:=False, Comma:=False, Space:=True, Other:=False, FieldInfo _
        :=Array(Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), _
        Array(7, 1))
   Cells.Select
    Cells.EntireColumn.AutoFit
        Counter = 0
        Sheets.Add
    End If
Loop
Close #1
  Columns("A:A").Select
    Selection.TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _
        TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=True, _
        Semicolon:=False, Comma:=False, Space:=True, Other:=False, FieldInfo _
        :=Array(Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), _
        Array(7, 1))
   Cells.Select
    Cells.EntireColumn.AutoFit
    Application.ScreenUpdating = True
End Sub
__________________
Mojito connoisseur and a dabbler in Cisco
where does code go ?
look here
how to insert code

how to enter array formula


recommended reading
wiki Mojito

how to say no convincingly

most important think you need
Reply With Quote