open text file to extract data

S

S.E.

I am only familiar with the very basics of writing macros, but I am trying
my hand at writing my first one with hopes of learning more.

I want to write a macro that will save me a lot of repetitive work. The
first step is to open a text file in order to extract some data that I can
manipulate in Excel. When I do it without a macro, the text import wizard
opens and I am able to import the data as from a fixed width file. What I
have tried in the macro is not working:

Public Sub prepareImport()
fileToOpen = Application.GetOpenFilename("Text Files (*.txt), *.txt")
Open "fileToOpen" For Random As #2
End Sub

Does anyone have ideas to help me get started?

Thanks in advance,
Scott
 
D

Dave Peterson

Try recording a macro when you do it manually.

Post back with your recorded code if you have questions.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top