Solved

template creation template

Posted on 2014-10-21
2
68 Views
Last Modified: 2014-10-22
I don't have the slightest idea on what this is called so I will just describe it.  I have a file layout of a text file that identifies that text and what they mean in this garbage of a text file

example
character 1 - 10 address
11 - 35 last name.
36 - 47 state
48 - 54 state bird

when I import it into excel I have to used a character with tool to define the columns.  is there anyway to repeat this process for the same file layouts so I don't have to adjust the bars everytime?  I do this daily.
0
Comment
Question by:jamesmetcalf74
2 Comments
 

Author Comment

by:jamesmetcalf74
ID: 40395622
this is the process defined by msft.  can I automate this?

http://office.microsoft.com/en-us/excel-help/text-import-wizard-HP010102244.aspx
0
 
LVL 27

Accepted Solution

by:
Glenn Ray earned 500 total points
ID: 40395953
Yes, you can automate this using VBA.  This code will import a text file with your defined column specifications:
Option Explicit
Sub Import_Text()
    Dim strFileName, strWkbkName As String
    strFileName = Application.GetOpenFilename
    If strFileName = "" Or strFileName = "False" Then Exit Sub
    Workbooks.OpenText Filename:=strFileName, Origin:=437, StartRow:=1, _
        DataType:=xlFixedWidth, FieldInfo:=Array(Array(0, 1), Array(10, 1), _
        Array(35, 1), Array(47, 1))
    Cells.Select
    Cells.EntireColumn.AutoFit
End Sub

Open in new window


I attached an example file with this code.  Just press the button, browse and locate your file and click the "Open" button.  The data will be inserted in four columns.

Regards,
-Glenn
EE-ImportText.xlsm
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question