Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need ExcelMacro Help

Status
Not open for further replies.

jonsi

IS-IT--Management
Dec 20, 2001
1,989
DE
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?"
 
Use Application.GetOpenFilename and Application.GetSaveAsFilename with customised parameters to allow user select input and define output files.

combo
 
Hi,

Please post VBA/macro questions in forum707. Please re-post this question.

In the mean while, check out GetOpenFileName()
 
Thx Skip

Duly reposted

hwyl
Jonsi B-)
"If an apple a day keeps the Doctor away ...why don't Daleks live in Orchards?"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top