Getting text file into excell

Hello.

I have text files which are loaded to excell.
The text files are always of the same format.

I want to load the file, but always I need to mark the positions of the
current loaded file.

How can I load the file always in a fixed format (can I do a templette for
that ?)

Thanks :)


0
Mr
7/29/2003 6:51:52 PM
excel 39879 articles. 2 followers. Follow

4 Replies
367 Views

Similar Articles

[PageSpeed] 45

Mr. J. wrote:
> I have text files which are loaded to excell.
> The text files are always of the same format.
>
> I want to load the file, but always I need to mark the positions of
> the current loaded file.
>
> How can I load the file always in a fixed format (can I do a
> templette for that ?)

I just did something very similar last week.  I recorded a macro and then
modified the code slightly to meet my needs.  To record a macro, Tools |
Macro | Record new macro....  Then you perform your typical text loading
function and stop the macro recorder.  To edit the macro, Tools | Macro |
Macros | (select the macro) Run.

My macro looks like the following.  I added the second line to give a prompt
for a new filename each time I execute the macro.  You might like to use
that (or you might not :).

Sub open_ascii_file()
    DirName = "C:\files\pathname"
    Filename = InputBox("Enter a filename")
    Workbooks.OpenText Filename:=DirName & Filename, Origin:=xlWindows,
StartRow:= _
        9, DataType:=xlFixedWidth, FieldInfo:=Array(Array(0, 1), Array(12,
1), Array(25 _
        , 1), Array(38, 1), Array(51, 1), Array(64, 1), Array(77, 1),
Array(90, 1), Array(103, 1), _
        Array(116, 1), Array(129, 1), Array(142, 1), Array(155, 1),
Array(168, 1), Array(181, 1), _
        Array(194, 1), Array(207, 1), Array(220, 1), Array(233, 1),
Array(246, 1), Array(259, 1), _
        Array(272, 1), Array(285, 1), Array(298, 1), Array(311, 1),
Array(324, 1), Array(337, 1), _
        Array(350, 1))
End Sub

Dave
dvt at psu dot edu


0
dvt (216)
7/29/2003 6:31:10 PM
Thanks :)
How can I load a macro after I saved it in *.bas (vb file) into excell ?

"dvt" <dvt@nospam.psu.edu> wrote in message
news:uyWcQYgVDHA.3376@tk2msftngp13.phx.gbl...
> dvt wrote:
> > Sub open_ascii_file()
> [snip]
> > End Sub
>
> Sorry about the word wrap.  Let me try a second time....
>
> Sub open_ascii_file()
>     DirName = "C:\files\pathname"
>     Filename = InputBox("Enter a filename")
>     Workbooks.OpenText Filename:=DirName & Filename, _
>        Origin:=xlWindows, StartRow:= 9,_
>        DataType:=xlFixedWidth, FieldInfo:=Array(Array(0, 1),_
>        Array(12, 1), Array(25 , 1), Array(38, 1), Array(51, 1), _
>        Array(64, 1), Array(77, 1), Array(90, 1), Array(103, 1), _
>        Array(116, 1), Array(129, 1), Array(142, 1), Array(155, 1),_
>        Array(168, 1), Array(181, 1), Array(194, 1), Array(207, 1),_
>        Array(220, 1), Array(233, 1), Array(246, 1), Array(259, 1), _
>        Array(272, 1), Array(285, 1), Array(298, 1), Array(311, 1),_
>        Array(324, 1), Array(337, 1), Array(350, 1))
> End Sub
>
>
>


0
Mr
7/30/2003 7:52:47 AM
Mr. J. wrote:
> How can I load a macro after I saved it in *.bas (vb file) into
> excell ?

I'm not sure how to do it from a .bas file.  I only know how to do this from
the VB editor in Excel.

In Excel, hit alt-F11.  Click Insert | Module.  Copy the code from your
*.bas file, paste it into the window you just created.  Go back to the
spreadsheet, click Tools | Macro | Macros.  Select the appropriate macro and
click Run.

Does this help?

Dave
dvt at psu dot edu


0
dvt (216)
7/30/2003 4:49:26 PM
Thanks :)

"Gord Dibben" <gdibben@shaw.ca> wrote in message
news:ks4giv4rp1oqno5glcs6cms5o4dtd8br5g@4ax.com...
> With Excel open hit ALT + F11
>
> Select your workbook/project and right-click>Import File.
>
> You will be presented with a dialog box(file types .bas, .frm, .cls).
Browse
> to your *.bas file and "Open".  It will be imported as a new Module.
>
> Gord Dibben  Excel MVP - XL97 SR2 & XL2002
>
> On Wed, 30 Jul 2003 12:49:26 -0400, "dvt" <dvt@nospam.psu.edu> wrote:
>
> >Mr. J. wrote:
> >> How can I load a macro after I saved it in *.bas (vb file) into
> >> excell ?
> >
> >I'm not sure how to do it from a .bas file.  I only know how to do this
from
> >the VB editor in Excel.
> >
> >In Excel, hit alt-F11.  Click Insert | Module.  Copy the code from your
> >*.bas file, paste it into the window you just created.  Go back to the
> >spreadsheet, click Tools | Macro | Macros.  Select the appropriate macro
and
> >click Run.
> >
> >Does this help?
> >
> >Dave
> >dvt at psu dot edu
> >
>


0
Mr
7/31/2003 7:08:34 AM
Reply:

Similar Artilces:

Word 2010 beta: Cannot save my Normal.dotm file
Using the Word 2010 beta on Win7. I cannot save my Normal.dotm file - at least not usefully. I can open the file, edit it, add macros to it, whatever, and it will save (in the folder directory, the .dotm file will show a change in file size). But when I close Word, or if I open a new document in Word, the Normal.dotm file is reset to the default, losing any changes I've made. I can save and use other .dotm templates; but not the default Normal.dotm template. http://social.technet.microsoft.com/Forums/en/category/office2010 -- Susan Ramlet -- please reply to the newsgroup...

data input in text box
We have a form which the operator enters data in a text box. Currently we have a 'done' button on the form that the operator clicks to send the text box info to a vba program. How can we send the text box info to the vba program when the operator hits the enter key @ the end of the data entry for the text box? TIA -- _______________________________ In Christ's matchless name ted & colleen n6trf kc6rue Use the control's AfterUpdate event. -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "ted" <n6trf@arr...

how do I automatically update a text box in a chart?
Hi, You can link the textbox to a cell. When you update the cell the textbox should reflect this. Select the textbox border and then in the formula bar enter the complete cell reference, for example, =Sheet1!A1 Cheers Andy Kath wrote: -- Andy Pope, Microsoft MVP - Excel http://www.andypope.info ...

Excel 2007
When I select cells to copy as a picture in Excel 2007, the resolution is terrible. Text and objects with shadow's are very blotchy when pasting the picture. How do you change the resolution of a 'Copy Picture'? ...

Input Excel 'Password to Open' through control in access form
Hi All, We know,Excel has prompt password to open it files. Is it possible to create a code that can supplies the excel prompt password?.So that when we open the excel file through our access control in a form, the excel files can be opened automatically.But when the excel files opened from its default icon,it will prompt a password first. ...

Excel not Access
I have designed an Access database that holds records relating to my stores audit results going back for about 5 years plus a load more information relating to these stores. This was used to produe a pack once a month, however a change in senior management means that I have got to shelve this and prodce a similar pack in Excel. The idea would be that the user could select a month or a 12 mnth date range that would produce data that could then be used to populate a number of excel templates that have been designed. Having not used excel for years I would be grateful for any suggestion...

How to keep format when importing Excel into SQL.
Can anybody help me please? When I import Excel file into SQL, a field that formated as 0000000000 (custom), loosing leading zeros. I tried to change data type in SQL after importing. No luck. I appretiate any help. See if using IMEX=1 helps: http://pratchev.blogspot.com/2007/10/importing-excel-data-into-sql-server.html -- Plamen Ratchev http://www.SQLStudio.com Plamen, I tried this, but got an error: "The OLE DB provider "Microsoft.Jet.OLEDB.4.0" has not been registered." Thank you very much for looking into this. "Plamen Ratchev" wr...

Auto-format in Microsoft Excel.
Each time i try to enter a number range, for example, 8- 10, in Excel, it constantly re-formats it to a date. If I change the formatting to "General" it turns it into a random number, usually 38209. I would like to turn off ALL auto-formatting, but that's probably asking too much. How do I disable this frustrating feature? thanks. Hi Paul When you enter "8-10" in a cell, that's not strictly a number but Excel thinks you mean a date so converts it as such. A date is a number and in your example the number 38209 represents August 10 2004 which is not a ra...

MS Money 95 data files
I hope that some one can answer this for me. I have used MS Money 95 for years, and it works just fine for me on Windows XP, however, I now have to reformat my hard drive, and have discovered that I can nolonger find my original install disk. Will the latest versions of Money still read the MS Money 95 data files. All that I have ever used the program for is to track my investments, and am unlikely to do any different in the future. Thanks Stan B In microsoft.public.money, Stan Banner wrote: >I hope that some one can answer this for me. >I have used MS Money 95 for years, and...

How to change font size on formula bar in Excell 2007
I don't find Tools>Options>General (as suggested in other post answers) in Excel 2007. On the Office button there is an Excel Options but it doesn't provide a method of changing font size on the office but. My font is so small I can barely see it. Office button>ExcelOptions>Popular tab>in the "When creating new workbooks" section, choose font and font size -- Kind regards, Niek Otten Microsoft MVP - Excel "jimwillie" <jimwillie@discussions.microsoft.com> wrote in message news:588AAC05-0F52-404E-AA01-128E70E02D0B@microso...

Opening Excel Workbooks
I'm running into an issue where if I click on an Excel file through My Documents, it doesn't automatically bring it up. I get the toolbar but the actual spreadsheet doesn't appear on the screen. I have to click on the taskbar to get it to pop up. If I already have Excel active and I open a file through Excel, this doesn't happen. Any ideas? Here is a similar thread: http://www.excelforum.com/showthread.php?s=&threadid=237195 Rolli -- Message posted from http://www.ExcelForum.com Hi, Take a look at Tools-Options-General tab- uncheck ignore other application...

Unexpected error message on closing an Excel file
Suddenly I am getting the following message when I try to close a workbook: "Your formula contains an invalid external reference to a worksheet. Verify that the path, workbook, and range name or cell reference are correct, and try again" The mysterious thing is that it does not happen consistently and that, after I click OK after the above message, I can still save the file. What might be the cause of this error message and can the "invalid reference" be tracked down using one of the utility add-ins such as J. Walkenbach's PUP? If it only happens when you close ...

Where is the workspace file stored?
I was given a project folder containing several dozen files. So where is the workspace file normally located? If I don't have a workspace file how can I cerate one? Using VC version 6. TIA I haven't used VC6 for some time, but if I remember right you can just open the .dsp file and it will create a .dsw file for you. It typically goes in the same folder with the code. Tom "Phisherman" <noone@nobody.com> wrote in message news:be93539ccf8a6f25ibh4vt6ggmtbi024mq@4ax.com... >I was given a project folder containing several dozen files. So where > is the wor...

help with simple maths in excel
I want to do a simple arithmatic excercise in excel for my grand daughter. It is stuff like 2+2 =4 Smart me has hit a problem at the first hurdle... I need to put 2 in one cell the + in another cell and then 2 in another = in another and then she puts the answer in the next one. So the above would have 4 cells completed and she would put the answer in the 5th one. When I use the + or = sign in a cell of its own it (excel) thinks I am doing an equation, is there a way around this? I will work on the answer like if she gets it correct or wrong how I will do that...a sound or som...

Change File Locations to Private Drive (not Folder)
Hi, I know that I can use "File Locations" in "Options" so that whenever I use the "Open..." command in Word, it will open to a specific folder. I'm wondering if there is a way that this can be applied not to a folder but to a specific drive on a network. Our company has a main public drive and has also assigned each of the Staff their own private drive. Is there a way to access the "main page" (for lack of a better term) of my private drive each time I use "Open..." in Word? Right now it goes to "My Computer" or ...

cant start outlook pst file to large
Hi I hope somebody may be able to help im new to outlook and now I cant start outlook message says cannot open your default email folders pst file its too large as I cannot open outlook I cannot delete old folders See if this helps: http://support.microsoft.com/kb/296088 -- -Ben- Ben M. Schorr, MVP Roland Schorr & Tower http://www.rolandschorr.com http://www.officeforlawyers.com/outlook.html Author: The Lawyer's Guide to Microsoft Outlook 2007: http://tinyurl.com/ol4law-amazon "Ray" <Ray@discussions.microsoft.com> wrote in message news:B3B824DC-3C9B-4B1B-8EF3-61...

"Save" preferences getting lost
List members: I work on long documents and want to save my work frequently. Every time I set the "Save" preference to a brief interval like five or ten minutes, the preferences seemingly resets itself to a default of thirty minutes. I'm using Word 2008 for the Mac on an Intel running 10.6.2. Thanks in advance for any thoughts. - Mark Pavlick Hi Mark: That indicates that your user ID does not have permission to write to the preference file that Word is using, or that something is replacing the preference file. With the help of your System...

How to get rid of personal folders view in nagivation pane with MA
Hi, trying to help a friend who migrated to hosted mail with MAPI. She is running Oultlook 2003 with latest updates. In the navigation there are personal folders and MAPI folders. The personal folders always show at top and expanded, with the MAPI folders below and not expanded. She only wants to see the MAPI folders expanded in the navigation view. I tried deleting the personal folders and it would not let me and it will not let you deliver to MAPI, which I understand why. Does anyone know how to make this happen? Thanks. Is this a hosted Exchange account? You can change the...

How To Copy MS Word mailing labels into Excel
I have a word doc that I want to put into Excel. I want to add some more fields to the names and addresses. Is this simple or do I have to learn how to program? Michael Rodriguez City of Grand Prairie Michael, have you tried to copy and paste the data into excel? -- Paul B Always backup your data before trying something new Please post any response to the newsgroups so others can benefit from it Feedback on answers is always appreciated! Using Excel 2000 & 97 ** remove news from my email address to reply by email ** "Michael Rodriguez" <mrodrigu@gptx.org> wrote in messa...

Lookup text with multiple search criteria
I know how to look up data and text using vlookup and hlookup, what I' like to know is whether there is a way of looking up data based on mor than 1 search criteria; for example If I wanted to look up an item in a 4 column database, I'd us something like this: =VLOOKUP("Apples",A2:D10,4,false) But that only looks for Apples. Say I wanted to lookup data based on subcategory of Apples, e.g. colour. If it was a number, I could use SUMPRODUCT and (assuming named range were in use) do it like this: =SUMPRODUCT((Fruit="Apples)*(Colour="Red")*(Total)) But obvio...

How do I use traffic lights in excel
I am wanting to use traffic lights in excel that change colour based on the result of a variance cell, ie if the result of the cell is 10 make the traffic light green, if it is 20 make the traffic light amber, if the result is 30 make the traffic light red. How do I do this? Shorty Format>Conditional Formatting>Cell Value is: Note: you can add up to 3 conditions(4 if you count default) Gord Dibben Excel MVP On Wed, 22 Dec 2004 16:35:03 -0800, Shorty <Shorty@discussions.microsoft.com> wrote: >I am wanting to use traffic lights in excel that change colour based on the &g...

Drag and Drop file/directory names on Tree Control.
hi, I am writing an application in which i have one Tree control. Now i want that , when user drag & drop any file/folder on tree control the file name/folder name should be add in the tree control item. User may drag and drop file from desktop or may be from directory. I just want the path of that file/foder name nothing else. so plz tell me will it be possible ... Plz Help me............. Klic..... > I am writing an application in which i have one Tree control. >Now i want that , when user drag & drop any file/folder on tree >control the file nam...

Trying to read XML file into dataset
Hello. Developing a web site in VS2005, SP1, VB, .NET 2.0, ASP.NET 2.0 on XP Pro, SP2. I eventually want to use a gridview table to view xml data, but right now i can't seem to get my xml data into a dataset so that i can use it. I have an XML file and can open it in IE. There is no XSD or XSL file to go with it. I can't seem to get the XML data into a dataset. I tried using the following code, but it just does nothing. It doesn't give an error. It just executes the code and does nothing. Dim dataSet As DataSet = New DataSet dataSet.ReadXml("...

opening .bak file
Hi, I hope someone can help! I recently was performing a compacting operation on my outlook express folders. My computer shutdown due to a power failure and I lost some emails from a few of my folders. I was however able to get the .bak files (of the .dbx files that were lost) out of the recycle bin. If I could open one of these .bak files or convert it back to the .dbx file from which it was created I would retrieve these emails. Can anyone instruct me as to open this .bak file? Thanks for any help! Arnie K. How did you get the bak files out of the Recycle Bin? All e...

Calculating age in a label or text box on a form
Hello All, I have a text box for birthdate for a user to enter the birthdate and I want to the age for the user to be automatically calcuated and displayed in another label called "Age." What formula can I use? Missy ...