Solved

template creation template

Posted on 2014-10-21
2
64 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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
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.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

743 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

17 Experts available now in Live!

Get 1:1 Help Now