Saturday, August 13, 2011

How to Import More Than 65,536 Rows in Excel 2003


1. Click 'Tools,' select 'Macro' and choose 'Macros.'
2. Type a name for your macro in the 'Name' field, such as 'LargeFileImport,' and click 'Create.' The Visual Basic Editor will open automatically.
3. Double-click '(Name) Module' in the 'Properties' window and type 'LargeFileModule.'
4. Click the ' ' icon next to 'Microsoft Office Excel Objects.'
5. Double-click 'LargeFileModule' to open the 'Code' window.
6. Copy and paste the following into the 'Code' window:Sub LargeFileImport()'Dimension VariablesDim ResultStr As StringDim FileName As StringDim FileNum As IntegerDim Counter As Double'Ask User for File's NameFileName = InputBox('Please enter the Text File's name, e.g. test.txt')'Check for no entryIf FileName = '' Then End'Get Next Available File Handle NumberFileNum = FreeFile()'Open Text File For InputOpen FileName For Input As #FileNum'Turn Screen Updating OffApplication.ScreenUpdating = False'Create A New WorkBook With One Worksheet In ItWorkbooks.Add template:=xlWorksheet'Set The Counter to 1Counter = 1'Loop Until the End Of File Is ReachedDo While Seek(FileNum)
7. Click 'File' and select 'Close' to close the Visual Basic Editor.
8. Click 'Tools,' select 'Macro' and choose 'Macros.'
9. Select the 'LargeFileImport' macro from the 'Macros' dialog box and click 'Run.'
10. Enter the name of your file (myhugedocument.txt, for example) in the dialog box that appears. Excel will import the data, splitting it into multiple worksheets in order to circumvent Excel's line limit.

Blogger news