Link to home
Start Free TrialLog in
Avatar of Cartillo
CartilloFlag for Malaysia

asked on

Copy text file data in workbook.

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
Avatar of Jacques Geday
Jacques Geday
Flag of Canada image

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
Avatar of Cartillo

ASKER

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
Hi gowflow,

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

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

One more thing, can we make sure the "time" that we copied at column F is exactly same with the source file?  
ASKER CERTIFIED SOLUTION
Avatar of Jacques Geday
Jacques Geday
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi gowflow,

Thanks a lot for helping me create this code.
Your welcome. be my guest anytime.
gowflow