Open file path from cell, paste into new sheet named from another cell and loop

paddyde

New Member
Joined
Mar 7, 2019
Messages
2
Hi,

Ive found this forum enormously useful over many years without ever having to post a question. Invariably I'm able to find previously code that works for me with a bit of tweaking. So thanks already!

I need some VBA code to open a text file (they are text files with a *.WTS suffix, but they are text files and excel can open/import/read them no problem) and paste the contents of that text file into a new work sheet in the workbook and then loop through 225 files in total. I currently have a sheet in a workbook in which column A contains all of the file paths and column B contains the corresponding sheet name which I would like to apply to a new sheet into which the contents of the txt file are pasted.

I imagine this is pretty simple stuff - but Im hitting a complete block trying to get something that even begins to work. Could anyone lend a hand?

I cant post an attachment example file, but here is the example data in *.csv format:

file path,name for sheet
C:\xxxxx\SANDBOX\1\xxxx\xxxx\xxxx.WTS,1_A1_1_R1
C:\xxxxx\SANDBOX\2\xxxx\xxxx\xxxx.WTS,2_A1_1_R1
C:\xxxxx\SANDBOX\3\xxxx\xxxx\xxxx.WTS,3_A1_1_R1
C:\xxxxx\SANDBOX\4\xxxx\xxxx\xxxx.WTS,4_A1_1_R1
C:\xxxxx\SANDBOX\5\xxxx\xxxx\xxxx.WTS,5_A1_1_R1
C:\xxxxx\SANDBOX\6\xxxx\xxxx\xxxx.WTS,6_A1_1_R1
C:\xxxxx\SANDBOX\7\xxxx\xxxx\xxxx.WTS,7_A1_1_R1

Thanks for any help!
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college

Forum statistics

Threads
1,213,546
Messages
6,114,255
Members
448,556
Latest member
peterhess2002

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top