• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Copying Data from Files in Folder and Copying data to Master Sheet according to Headers

Seth

New Member
Hello all,

I'm new to coding vba. The goal of my macro would be to loop through all files in a folder running a macro that rearranges the files' format and copies the desired range. Then copy this range of data to a master sheet matching the data range to the correct header which is a date.

So far I have code on the personal workbook that formats the individual files and copies the data range I want. I know there is code that can loop this macro through a folder running it on each file; I just have not integrated this code with mine yet. But, I do not know how I will be to match the copied data from the individual files to the column headers they need to be pasted under. It'd be much appreciated if anyone could help with this.

This is the macro on the personal workbook that reformats the individual txt files and copies the desired range.

Original txt.png

The macro I have made rearranges for the desired data as below and is attached in the word file.

after mac.png

So the overall vba code should be activated by the Weld Scrap Dollars button, call my macro (which called WeldScrap()), and paste scrap dollar values to master sheet according to code and date.

transfer.png


Three sample .txt files are attached with the naming of elkhart in them. These would be in the folder that needs to be looped through. The master sheet is also attached, just look at the elkhart sheet since there are many other formulas and things in the sheet that don't pertain to the macro.

If anyone could help with this I'd really appreciate it!
 
Sorry I could only upload the images in my post, but here are the individual .txt files.
 

Attachments

  • Elkhart.txt
    7.5 KB · Views: 0
  • Elkhart May 15.txt
    6.1 KB · Views: 0
  • Elkhart May 14.txt
    6.4 KB · Views: 0
And here is the master sheet and already written code to rearrange .txt files.
 

Attachments

  • Personal Workbook Code.docx
    15.4 KB · Views: 0
  • Scrap Master Sheet Rev2.xlsx
    24.4 KB · Views: 0
Back
Top