Solved

import data in excel  from text file

Posted on 2014-02-18
7
491 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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

770 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