# Trouble reading in txt file. Only want to read in certain columns.

Posted by Edward Clutter on February 15, 2001 1:48 PM

Hi Everyone,

I need to be able to read in 1 to 5 very large data files that are stored as *.txt files. I used the record macro feature to make the following macro. I basically used the open feature and deactivated all of the columns except the two I wanted. It works when I do it manually, but when I try to play back the macro, I get an "out of memory message". Anyone know why that is, and does anyone know of a better way to do what I want?

Thanks

Edward

Macro: (see listing below)

Sub read_in_data_file()

'

' read_in_data_file Macro

' Macro recorded 1/26/01 by clutter

'

'

Sheets("Sheet2").Select

ChDir "D:\Edward\Mercury_data_processing_010801\data\PPBreadboard\000911"

Workbooks.OpenText FileName:= _

"D:\Edward\Mercury_data_processing_010801\data\PPBreadboard\000911\MercuryBreadBBoard_20000909_1349.LOG" _

, Origin:=xlWindows, StartRow:=1, DataType:=xlDelimited, TextQualifier _

:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:= _

False, Comma:=False, Space:=False, Other:=False, FieldInfo:=Array(Array _

(1, 2), Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), Array(7, 1), Array(8 _

, 1), Array(9, 1), Array(10, 1), Array(11, 1), Array(12, 1), Array(13, 1), Array(14, 1), _

Array(15, 1), Array(16, 1), Array(17, 1), Array(18, 1), Array(19, 1), Array(20, 1), Array( _

21, 1), Array(22, 1), Array(23, 1), Array(24, 1), Array(25, 1), Array(26, 1), Array(27, 1), _

Array(28, 1), Array(29, 1), Array(30, 1), Array(31, 1), Array(32, 1), Array(33, 1), Array( _

34, 1), Array(35, 1), Array(36, 1), Array(37, 1), Array(38, 1), Array(39, 1), Array(40, 1), _

Array(41, 1), Array(42, 1), Array(43, 1), Array(44, 1), Array(45, 1), Array(46, 1), Array( _

47, 1), Array(48, 1), Array(49, 1), Array(50, 1), Array(51, 1), Array(52, 1), Array(53, 1), _

Array(54, 1), Array(55, 1), Array(56, 1), Array(57, 1), Array(58, 1), Array(59, 1), Array( _

60, 1), Array(61, 1), Array(62, 1), Array(63, 1), Array(64, 1), Array(65, 1), Array(66, 1), _

Array(67, 1), Array(68, 1), Array(69, 1), Array(70, 1), Array(71, 1), Array(72, 1), Array( _

73, 1), Array(74, 1), Array(75, 1), Array(76, 1), Array(77, 1), Array(78, 1), Array(79, 1), _

Array(80, 1), Array(81, 1), Array(82, 1), Array(83, 1), Array(84, 1), Array(85, 1), Array( _

86, 1), Array(87, 1), Array(88, 1), Array(89, 1), Array(90, 1), Array(91, 1), Array(92, 1), _

Array(93, 1), Array(94, 1), Array(95, 1), Array(96, 1), Array(97, 1), Array(98, 1), Array( _

99, 1), Array(100, 1))

ActiveWindow.ScrollWorkbookTabs Position:=xlFirst

ActiveWindow.ScrollWorkbookTabs Position:=xlLast

Columns("A:A").EntireColumn.AutoFit

ActiveWindow.ScrollWorkbookTabs Position:=xlFirst

ActiveWindow.ScrollWorkbookTabs Position:=xlFirst

ActiveWindow.SmallScroll Down:=33

ActiveWindow.ScrollRow = 17028

ActiveWindow.ScrollRow = 26783

ActiveWindow.ScrollRow = 29207

ActiveWorkbook.SaveAs FileName:= _

"D:\Edward\Mercury_data_processing_010801\data\PPBreadboard\000911\data.xls", _

FileFormat:=xlNormal, Password:="", WriteResPassword:="", _

ReadOnlyRecommended:=False, CreateBackup:=False

Range("A29210").Select

Workbooks.Open FileName:= _

"D:\Edward\Mercury_data_processing_010801\data\testcase.xls"

Range("B15").Select

ActiveWorkbook.Close

ActiveWorkbook.Close

Sheets("Sheet2").Select

Sheets("Sheet2").Name = "Data"

Range("A1").Select

Workbooks.Open FileName:= _

"D:\Edward\Mercury_data_processing_010801\data\PPBreadboard\000911\data.xls"

ActiveWindow.Visible = False

ActiveSheet.OLEObjects.Add(FileName:= _

"D:\Edward\Mercury_data_processing_010801\data\PPBreadboard\000911\data.xls", _

Link:=False, DisplayAsIcon:=False).Select

Sheets("AutoPlot - GUI").Select

ActiveWorkbook.Save

Sheets("Data").Select

Windows("Worksheet in autoplot_devl_012601").Visible = True

Selection.Verb Verb:=xlPrimary

ActiveWindow.WindowState = xlMaximized

Range("B29214").Select

ActiveWorkbook.Close

Sheets("AutoPlot - GUI").Select

ActiveWorkbook.Save

End Sub