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!
 

Some videos you may like

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

Watch MrExcel Video

Forum statistics

Threads
1,108,509
Messages
5,523,313
Members
409,511
Latest member
hitesh222002

This Week's Hot Topics

Top