Solved

template creation template

Posted on 2014-10-21
2
67 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

776 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