Solved

import data in excel  from text file

Posted on 2014-02-18
7
492 Views
Last Modified: 2014-02-25
Hi Experts,

I have 100000 lines in text file which are in file 'current' format.
request to achieve the format as in  'final' excel fromat

the VB script should be able to match the column heading and have data in the corresponding rows.


It would be ideal: If the column heading does not exist script should be able to create a heading too.
Current.txt
final.xlsx
0
Comment
Question by:macentrap
  • 4
  • 3
7 Comments
 
LVL 29

Expert Comment

by:gowflow
ID: 39870350
1. Can we assume that the header in the xlsx will be there when we import the data ? as you may notice it is not always that all fields in each group that are represented, so it would be better to have at least the header to start with. Can we assume that ?

2. Can you post a .txt that have a bit more records ? no need for 100000 but 2 only is really the low end.

gowlfow
0
 
LVL 29

Accepted Solution

by:
gowflow earned 500 total points
ID: 39870552
I have assumed that the header is there in the final output.

1) Please make sure macros are activated
2) I created a backup of your sheet1 so you can compare the results.
3) I created Sheet2 where I pasted on the header. Position yourself in Sheet2 actually for this macro to run oyu only need to be positioned in the sheet where you need to data to be extracted to,
4) Go to Developper Tab and press on Macro and select ImportText and check the results.

For sure it would be better to have more data so we can check if all is ok.

Regards
gowflow
final-V01.xlsm
0
 
LVL 7

Author Comment

by:macentrap
ID: 39871519
Thank you gowflow, i will try soon and update
have attached current file with more data set
Current.txt
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
LVL 29

Expert Comment

by:gowflow
ID: 39872587
I tried the attached file and for me its fine, but will leave it to the Expert who knows better his own job to decide.
gowflow
0
 
LVL 7

Author Comment

by:macentrap
ID: 39885357
Thank you gowflow it works.
 Apologies for late reply.
0
 
LVL 7

Author Closing Comment

by:macentrap
ID: 39885358
great script
0
 
LVL 29

Expert Comment

by:gowflow
ID: 39885384
Glad I could help
gowflow
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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 is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

808 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