Hello
I am using Excel 2003. I have many .txt files to import into Excel with specific column data types. I used the macro recording and got the following:
The files aren't named the same but have the same structure. How would I now take this and create a button to run the macro but prompt the user for the proper folder/file to import?
Thanks very much.
I am using Excel 2003. I have many .txt files to import into Excel with specific column data types. I used the macro recording and got the following:
Code:
Sub ImportRegrouped()
Workbooks.OpenText Filename:= _
"E:\My Documents\MyFile.txt"_
, Origin:=437, 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, 2), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 2), Array(7, 2), Array(8, 2), _
Array(9, 2), Array(10, 4), Array(11, 1), Array(12, 4), Array(13, 1), Array(14, 1), Array(15 _
, 2), Array(16, 2), Array(17, 2), Array(18, 2), Array(19, 2), Array(20, 2), Array(21, 2), _
Array(22, 2), Array(23, 2), Array(24, 2), Array(25, 2), Array(26, 1), Array(27, 2), Array( _
28, 1), Array(29, 1), Array(30, 1), Array(31, 2), Array(32, 2), Array(33, 2), Array(34, 2), _
Array(35, 2), Array(36, 2), Array(37, 2), Array(38, 2), Array(39, 1), Array(40, 1), Array( _
41, 1), Array(42, 2), Array(43, 2), Array(44, 1), Array(45, 1), Array(46, 2), Array(47, 2), _
Array(48, 2), Array(49, 2), Array(50, 2), Array(51, 2), Array(52, 2), Array(53, 2), Array( _
54, 2), Array(55, 2), Array(56, 2), Array(57, 2), Array(58, 2), Array(59, 2), Array(60, 2), _
Array(61, 2), Array(62, 2), Array(63, 2), Array(64, 2), Array(65, 2), Array(66, 2), Array( _
67, 2)), TrailingMinusNumbers:=True
End Sub
The files aren't named the same but have the same structure. How would I now take this and create a button to run the macro but prompt the user for the proper folder/file to import?
Thanks very much.