Solved

template creation template

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

867 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now