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 Original txt.png](https://chandoo.org/forum/data/attachments/20/20747-b9c18b0454491dbf893272183c089da4.jpg)
The macro I have made rearranges for the desired data as below and is attached in the word file.
![after mac.png after mac.png](https://chandoo.org/forum/data/attachments/20/20748-a8a7fec60be43684459858ae8dee2643.jpg)
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.
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!
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 Original txt.png](https://chandoo.org/forum/data/attachments/20/20747-b9c18b0454491dbf893272183c089da4.jpg)
The macro I have made rearranges for the desired data as below and is attached in the word file.
![after mac.png after mac.png](https://chandoo.org/forum/data/attachments/20/20748-a8a7fec60be43684459858ae8dee2643.jpg)
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 transfer.png](https://chandoo.org/forum/data/attachments/20/20749-285f69209181a2d9addd33a625efc18e.jpg)
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!