It is some while since I used a Macro in Excel but I have a lot of Data gathering from old .txt files that I need to do.
I have lots of data from a logger output into a .txt file. I need to fetch all of the data from columns A:I and dump it into another file which contains formulas.
the following Macro is recorded in the destination workbook
Sub fetch()
'
' fetch Macro
'
' Keyboard Shortcut: Ctrl+q
'
Workbooks.OpenText Filename:= _
"G:\folder\subfolder\txtfile.ext", Origin:=932, StartRow _
:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, Comma:=True, _
Space:=False, 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), Array(8, 1), Array(9, 1), Array(10 _
, 1), Array(11, 1)), TrailingMinusNumbers:=True
Columns("A:I").Select
Selection.Copy
Windows("destination.xlsm").Activate
Range("A1").Select
ActiveSheet.Paste
Selection.ColumnWidth = 8.29
Columns("A:A").EntireColumn.AutoFit
End Sub
I open the destination workbook first, then run the macro, but need it to 'fetch' data from a different txtfile everytime (the red bit in the macro). The destination workbook is then Save As NEWFILENAME.xlsx, leaving the original untouched.
How do I get the macro to wait for me to select the file? (the txtfile to be selected would always be in the same folder\subfolder)
thanx
Jonsi
hwyl
Jonsi B-)
"If an apple a day keeps the Doctor away ...why don't Daleks live in Orchards?"
I have lots of data from a logger output into a .txt file. I need to fetch all of the data from columns A:I and dump it into another file which contains formulas.
the following Macro is recorded in the destination workbook
Sub fetch()
'
' fetch Macro
'
' Keyboard Shortcut: Ctrl+q
'
Workbooks.OpenText Filename:= _
"G:\folder\subfolder\txtfile.ext", Origin:=932, StartRow _
:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, Comma:=True, _
Space:=False, 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), Array(8, 1), Array(9, 1), Array(10 _
, 1), Array(11, 1)), TrailingMinusNumbers:=True
Columns("A:I").Select
Selection.Copy
Windows("destination.xlsm").Activate
Range("A1").Select
ActiveSheet.Paste
Selection.ColumnWidth = 8.29
Columns("A:A").EntireColumn.AutoFit
End Sub
I open the destination workbook first, then run the macro, but need it to 'fetch' data from a different txtfile everytime (the red bit in the macro). The destination workbook is then Save As NEWFILENAME.xlsx, leaving the original untouched.
How do I get the macro to wait for me to select the file? (the txtfile to be selected would always be in the same folder\subfolder)
thanx
Jonsi
hwyl
Jonsi B-)
"If an apple a day keeps the Doctor away ...why don't Daleks live in Orchards?"