Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
Convert textfiles into excel
Hi
I have text files with more than 65536 lines which I want to convert to excel (I don't want to get into ACCESS, Foxpro,etc). It must copy, say, 60000 into sheet1; copy 60001-120000 into sheet2, and so on till the entire text file is converted. Regards Mani |
#2
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
Convert textfiles into excel
Mani,
Below is the standard large file import macro... HTH, Bernie MS Excel MVP Sub LargeFileImport() 'Dimension Variables Dim ResultStr As String Dim FileName As String Dim FileNum As Integer Dim Counter As Double 'Ask User for File's Name FileName = Application.GetOpenFilename 'Check for no entry If FileName = "" Then End 'Get Next Available File Handle Number FileNum = FreeFile() 'Open Text File For Input Open FileName For Input As #FileNum 'Turn Screen Updating Off Application.ScreenUpdating = False 'Create A New WorkBook With One Worksheet In It Workbooks.Add Template:=xlWorksheet 'Set The Counter to 1 Counter = 1 'Loop Until the End Of File Is Reached Do While Seek(FileNum) <= LOF(FileNum) 'Display Importing Row Number On Status Bar Application.StatusBar = "Importing Row " & _ Counter & " of text file " & FileName 'Store One Line Of Text From File To Variable Line Input #FileNum, ResultStr 'Store Variable Data Into Active Cell If Left(ResultStr, 1) = "=" Then ActiveCell.Value = "'" & ResultStr Else ActiveCell.Value = ResultStr End If If ActiveCell.Row = 60000 Then 'If On The Last Row Then Add A New Sheet ActiveWorkbook.Sheets.Add Else 'If Not The Last Row Then Go One Cell Down ActiveCell.Offset(1, 0).Select End If 'Increment the Counter By 1 Counter = Counter + 1 'Start Again At Top Of 'Do While' Statement Loop 'Close The Open Text File Close 'Remove Message From Status Bar Application.StatusBar = False End Sub "Maniv" wrote in message ... Hi I have text files with more than 65536 lines which I want to convert to excel (I don't want to get into ACCESS, Foxpro,etc). It must copy, say, 60000 into sheet1; copy 60001-120000 into sheet2, and so on till the entire text file is converted. Regards Mani |
#3
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
Convert textfiles into excel
Hi Bernie Thanks a ton.. I have been going through the various replies / code that you post at this portal.. Pl keep up the good work.. Warm regards Mani "Bernie Deitrick" wrote: Mani, Below is the standard large file import macro... HTH, Bernie MS Excel MVP Sub LargeFileImport() 'Dimension Variables Dim ResultStr As String Dim FileName As String Dim FileNum As Integer Dim Counter As Double 'Ask User for File's Name FileName = Application.GetOpenFilename 'Check for no entry If FileName = "" Then End 'Get Next Available File Handle Number FileNum = FreeFile() 'Open Text File For Input Open FileName For Input As #FileNum 'Turn Screen Updating Off Application.ScreenUpdating = False 'Create A New WorkBook With One Worksheet In It Workbooks.Add Template:=xlWorksheet 'Set The Counter to 1 Counter = 1 'Loop Until the End Of File Is Reached Do While Seek(FileNum) <= LOF(FileNum) 'Display Importing Row Number On Status Bar Application.StatusBar = "Importing Row " & _ Counter & " of text file " & FileName 'Store One Line Of Text From File To Variable Line Input #FileNum, ResultStr 'Store Variable Data Into Active Cell If Left(ResultStr, 1) = "=" Then ActiveCell.Value = "'" & ResultStr Else ActiveCell.Value = ResultStr End If If ActiveCell.Row = 60000 Then 'If On The Last Row Then Add A New Sheet ActiveWorkbook.Sheets.Add Else 'If Not The Last Row Then Go One Cell Down ActiveCell.Offset(1, 0).Select End If 'Increment the Counter By 1 Counter = Counter + 1 'Start Again At Top Of 'Do While' Statement Loop 'Close The Open Text File Close 'Remove Message From Status Bar Application.StatusBar = False End Sub "Maniv" wrote in message ... Hi I have text files with more than 65536 lines which I want to convert to excel (I don't want to get into ACCESS, Foxpro,etc). It must copy, say, 60000 into sheet1; copy 60001-120000 into sheet2, and so on till the entire text file is converted. Regards Mani |
#4
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
Convert textfiles into excel
Kind of you to say, but, well, this code certainly isn't mine. It was
copied off the MS web site about the turn of the century ;-) Bernie MS Excel MVP "Maniv" wrote in message ... Hi Bernie Thanks a ton.. I have been going through the various replies / code that you post at this portal.. Pl keep up the good work.. Warm regards Mani |
#5
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
Convert textfiles into excel
I used the above script to import a text file with about 150k lines. All the
data was imported, but it never asked me how I wanted the columns formatted so everything was lumped into a single cell per row. Is there a way to have the wizard pop up and allow the user to determine where the column breaks should be and perhaps allow the user to select which row to start the import? The users will need to import various text files with different columns of data so I can not easily create a macro that will automatically separate the data into columns. The ability to use the wizard would be ideal. We are running Excel 2003 SP2. Any help would be appreciated. "Bernie Deitrick" wrote: Kind of you to say, but, well, this code certainly isn't mine. It was copied off the MS web site about the turn of the century ;-) Bernie MS Excel MVP "Maniv" wrote in message ... Hi Bernie Thanks a ton.. I have been going through the various replies / code that you post at this portal.. Pl keep up the good work.. Warm regards Mani |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Convert Project template for Excel | Excel Discussion (Misc queries) | |||
Running Excel 2000 VBA Application on Excel 2003 | Excel Worksheet Functions | |||
How do I convert Excel 2003 to Excel 98 format? | New Users to Excel | |||
How do I convert a csv file to an Excel file? | Excel Discussion (Misc queries) | |||
Improve Convert function in Excel | Excel Worksheet Functions |