Solved

import data in excel  from text file

Posted on 2014-02-18
7
489 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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 tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

910 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

16 Experts available now in Live!

Get 1:1 Help Now