Opening data file

jpen

Active Member
Joined
Jun 19, 2002
Messages
398
Hi all,

I have a directory with data files (txt format) which I import in Excel. Now I want to start a macro at the moment I select one of these files. How can I do this??

Thanks
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

ChrisUK

Well-known Member
Joined
Sep 3, 2002
Messages
675
Why not use your macro to open the file then call the macro you want directly afterwards.

To open a file for import then execute another macro afterwards use this code.

Workbooks.OpenText Filename:="C:Filesmyfile.txt", Origin:=xlWindows _
, StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, Comma:=False _
, Space:=False, Other:=False, FieldInfo:=Array(1, 1)

Call mymacro


Hope this helps
 

jpen

Active Member
Joined
Jun 19, 2002
Messages
398
The problem is that the filename in the macro is not a variabel. I have about 100 data files (all having another name) which I want to import in Excel.
 

Forum statistics

Threads
1,181,645
Messages
5,931,195
Members
436,781
Latest member
acyiang

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top