+ Reply to Thread
Results 1 to 4 of 4

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

  1. #1
    Registered User
    Join Date
    05-30-2014
    Posts
    11

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

    Hi,

    I'm a fairly basic user of VBA and have found this forum enormously useful over the years. Invariably there's already some code posted somewhere that I can find and modify to suit my needs, but this time I'm drawing a blank.

    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 listed in the worksheet. I currently have a sheet in a workbook in which column A contains all of the file paths for all the files and column B contains the corresponding sheet name which I would like to apply to a new sheet into which the contents of each txt file are pasted.

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

  2. #2
    Forum Contributor sauerj's Avatar
    Join Date
    11-11-2009
    Location
    Lafayette, IN
    MS-Off Ver
    Excel 2019
    Posts
    163

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

    Give this a try. This logic depends on naming the range of file names in column A. Here I have named this range as "File_Names".
    There are other ways to loop down the list of file names; this is just one way.
    The attached file has been edited for this macro and for the named range ("File_Names").
    Note, I changed the file names & paths (in the attached file) so to work w/ my computer; you'll have to change them back for your computer. Hope this helps!
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    05-30-2014
    Posts
    11

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

    That works perfectly!

    Thank-you!

  4. #4
    Forum Contributor sauerj's Avatar
    Join Date
    11-11-2009
    Location
    Lafayette, IN
    MS-Off Ver
    Excel 2019
    Posts
    163

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

    You're welcome! Please 'Add to My Reputation' if you feel I deserve it. I did for your nicely worded problem and quick 'thank you' on the solution. Cheer!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Trying to populate a cell with a file path within a loop
    By Groovicles in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-22-2016, 03:20 PM
  2. Open a Text File that is named in another cell, copy and paste all in another tab
    By Bobbbo in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-17-2016, 04:16 PM
  3. Open from dialog box to insert file path and name into cell
    By D_Rennie in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-13-2012, 02:29 AM
  4. [SOLVED] open variably named file, copy/paste data into consolidation file, open next file in list
    By sllawrence1968 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-29-2012, 09:49 PM
  5. [SOLVED] VBA - Open Excel Files with file path from Named Ranges
    By bbg22 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-06-2012, 11:41 PM
  6. Open File which path is in a cell
    By Bishonen in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-30-2012, 07:54 AM
  7. How do I open a file from a named cell?
    By Cumberland in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-23-2006, 04:15 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1