View Full Version : Import data from Text file using macros
mcgraw
04-11-2007, 10:20 PM
Hi
I am a newbie :friends:
I would like to do the following:
- have a set of data in text file (.txt) perhaps from Notepad
- import the data & paste into Excel , will be in 2 columns format
- plot a graph (x-y axes)
As simple as that but I don't know how to do it using VBA macros
Please advise :help
TQ
Charlize
04-12-2007, 12:20 AM
Sample of the structure of your textfile. How are the columns seperated ? A "/" or "#" or ... and how does the result must look like ...
And maybe you can just use Data - Import and select the options that you want ...
Charlize
mdmackillop
04-12-2007, 12:22 AM
Hi McGraw,
Welcome to VBAX
Can you post a sample of your txt file so we can see what the layout/delimeters are. Use Manage Attachments in the Go Advanced section.
What type of graph are you looking for; the all have x-y axes.
Regards
MD
mcgraw
04-15-2007, 07:18 PM
thanks for the reply
actually i need an array of data like so:
1 2 3 4 5
6 7 8 9 10
etc.
to be put onto Excel using VBA , which will display instead of rows it will be just 2 columns (transposed) like so
1 6
2 7
3 8
4 9
5 10
I created a command Button to perform the importing job
but doesn't know the code/syntax
hope this helps
:doh:
TQ
mdmackillop
04-15-2007, 11:53 PM
A sample of your text file will tell us if the data is separated by commas, spaces, tabs etc., which will assist us in giving you a solution.
Charlize
04-16-2007, 12:31 AM
After some mindreading, I came up with this one. The last line of the file that needs to be imported, has to be a blank line (line with no data). You have to run the macro 'DoTheImport'
Hope this will help you a little.
Charlize
ps.: This is a modified version of a routine provided by mdmackillop
No header rows in destination sheet (is active sheet when macro starts to run)
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.