-
Import data from Text file using macros
Hi
I am a newbie
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
TQ
-
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
-
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
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
-
Re: Import data from Text file using macros
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
TQ
-
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.
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
-
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)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules