Solved

Copy text file data in workbook.

Posted on 2011-09-12
9
179 Views
Last Modified: 2012-06-27
Hi Experts,

I would like to request Experts help create a VBA code to extract data from .txt file (source) into DailyData workbook according to the header. I have copied a sample data in DailyData workbook for Experts perusal. I have copied the source (.txt) files in a D folder (D:\data) and the code should be able to loop copy the files without overwriting the old data. Hope Experts could help me create this feature. Attached the workbook and the data (source) file for Experts perusal.



DailyData.xls
source.txt
0
Comment
Question by:Cartillo
  • 5
  • 4
9 Comments
 
LVL 29

Expert Comment

by:gowflow
ID: 36521707
When you saiy:
I would like to request Experts help create a VBA code to extract data from .txt file (source) into DailyData workbook according to the header.
Does this mean that there is a possibility that the text file will have the fields in diffrent sorting and will need them to sort as the Excel header or they will come always in the same order ?

Will all your text files be in the same layout like ----------------- in the begining then data ?
Can you pls post also 2 or 3 more text files so I can build it with more files reading ?
gowflow
0
 

Author Comment

by:Cartillo
ID: 36521743
Hi gowflow,

The text files are always in the same format/structure, I have the 2 more sample files for your kind perusal.

source2.txt
source3.txt
0
 

Author Comment

by:Cartillo
ID: 36521862
Hi gowflow,

Hope the sample files gives better idea how the source would look like. Hope it's double.
0
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.

 
LVL 29

Expert Comment

by:gowflow
ID: 36521864
Hi Cartillo,
PLs find attached the Excel file make sure that macros are enabled. Press on the command button Import and see results. I may have to adjust it when you read more than 1 file !
Let me know anyway first attempt.
gowflow
DailyData.xls
0
 

Author Comment

by:Cartillo
ID: 36521885
Hi gowflow,

Thanks for the code, is that possible not to include the header from the source file?  
0
 

Author Comment

by:Cartillo
ID: 36521894
Hi gowflow,

One more thing, can we make sure the "time" that we copied at column F is exactly same with the source file?  
0
 
LVL 29

Accepted Solution

by:
gowflow earned 500 total points
ID: 36522259
Hi Cartillo,
Pls try this version. Version where:
1) Accept multiple files once prompt select all available files by highlighting all of them like click on the first and press shift then click on the last one.
2) header only printed once.
3) Time is correctly formated.

Pls advise your comments and modifications if required.
gowflow
DailyData.xls
0
 

Author Closing Comment

by:Cartillo
ID: 36523793
Hi gowflow,

Thanks a lot for helping me create this code.
0
 
LVL 29

Expert Comment

by:gowflow
ID: 36523840
Your welcome. be my guest anytime.
gowflow
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Excel formula Sumif not working 4 28
Excel IF formula 3 21
hi all how do i achive this formula in condtional formatting excel 6 19
Msgbox tickler 10 25
Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
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;…
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…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

777 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