Solved

import data in excel  from text file

Posted on 2014-02-18
7
483 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

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…
Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

758 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

21 Experts available now in Live!

Get 1:1 Help Now