View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Fixed Width Text Import Settings

I'm not sure this approaches best, but this is what I do:

Saved from a previous post:

Start a new workbook

Start recording a macro that will be stored in this macro workbook.

File|Open your text file that needs to be imported. Format it the way you
like. Insert columns, add headers, freeze panes, widen columns, add filters, do
the page setup--everything you can think of.

When you're done, save that workbook with the macro.

I like to put a big button from the Forms toolbar on the only worksheet in that
macro workbook and assign this macro to that big button. I'll add a few
instructions to that sheet, too.

If the file name to open is always the same and in the same location, then I'm
about done. If the location or file name changes, I'll tweak the code to ask
for the file.

My tweaked code could look a little like:

Option Explicit
Sub Testme01()

Dim myFileName As Variant

myFileName = Application.GetOpenFilename(filefilter:="Text Files, *.Txt", _
Title:="Pick a File")

If myFileName = False Then
MsgBox "Ok, try later" 'user hit cancel
Exit Sub
End If

Workbooks.OpenText Filename:=myFileName '....rest of recorded code here!

End Sub



Bryan wrote:

What's the best practice for saving the macro in excel for future use?
Thanks,

"Pete_UK" wrote:

You can record a macro while you do it once. Then in future you can just run
the macro again. You may need to edit the macro slightly if the filename
differs each time.

Hope this helps.

Pete

"Bryan" wrote in message
...
I'm importing raw data into excel and using fixed width import settings
have
everything looking the way I need it, but how can I save those settings so
I
don't have to make changes three times a week? If anyone has a suggestion
please reply..thanks!





--

Dave Peterson