+ Reply to Thread
Results 1 to 13 of 13

Automatically Insert file names into a spreadsheet. Files are all in a single folder.

  1. #1
    Forum Contributor
    Join Date
    01-30-2011
    Location
    Boston
    MS-Off Ver
    MS 365
    Posts
    225

    Automatically Insert file names into a spreadsheet. Files are all in a single folder.

    It would be a big time saver to figure out how to get file names entered into a spreadsheet.

    I have a folder name KEEPER with an unknown number of text files. I would like to figure out an automated way to get all the file names in KEEPER folder entered into an open spreadsheet named COMPARE. The spreadsheet is in the KEEPER folder location. Be best if the file extension is removed and the file names are entered on tab B beginning at Cell A1. Note the file names are fixed length and one word.

    Can this be simply done with minimal VBA code?

    Thanks for any direction.

    jj

  2. #2
    Forum Contributor
    Join Date
    01-09-2016
    Location
    Perth Western Australia
    MS-Off Ver
    Office 365
    Posts
    257

    Re: Automatically Insert file names into a spreadsheet. Files are all in a single folder.

    Hi

    The following vba will give you a list

    Please Login or Register  to view this content.

    Cheers

    Please ignore I mistakenly uploaded the incorrect code.
    Last edited by FoxSeaLady; 10-24-2018 at 02:21 PM. Reason: Uploaded incorrect code

  3. #3
    Forum Contributor
    Join Date
    01-30-2011
    Location
    Boston
    MS-Off Ver
    MS 365
    Posts
    225

    Re: Automatically Insert file names into a spreadsheet. Files are all in a single folder.

    Thanks FoxSeaLady-

    Please note the file location:
    C:\Desktop\Keeper

    The file I where I need the list created is called compare and it is in the folder named keeper. Where I want the list created is on Tab 2 which is also the tab name. The list hopefully would populate column1 beginning at cell A1.

    Not sure how to customize the code for my use.

    Thanks for any further assistance.

    John

  4. #4
    Forum Contributor
    Join Date
    01-09-2016
    Location
    Perth Western Australia
    MS-Off Ver
    Office 365
    Posts
    257

    Re: Automatically Insert file names into a spreadsheet. Files are all in a single folder.

    Hi

    Still getting to a solution. Question how many characters in the file name?

    Cheers

  5. #5
    Forum Contributor
    Join Date
    01-30-2011
    Location
    Boston
    MS-Off Ver
    MS 365
    Posts
    225

    Re: Automatically Insert file names into a spreadsheet. Files are all in a single folder.

    Always 10 - thanks.

    j

  6. #6
    Forum Contributor
    Join Date
    01-09-2016
    Location
    Perth Western Australia
    MS-Off Ver
    Office 365
    Posts
    257

    Re: Automatically Insert file names into a spreadsheet. Files are all in a single folder.

    Hi

    It has taken time but I think I have your Solution with the following VBA code:-
    Please Login or Register  to view this content.
    It may not be the tidiest but it works and is not a lot of code.

    I have attached a sample file. Note this works from in directory Keeper and will need saving once run.
    Cheers
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    01-30-2011
    Location
    Boston
    MS-Off Ver
    MS 365
    Posts
    225

    Re: Automatically Insert file names into a spreadsheet. Files are all in a single folder.

    This is fascinating - thanks. It list the txt file names but also the name of the Excel file itself - it put that in the same column. That's a small issue as there is a bunch of different file types and only want the text file names (minus the extension.) It is listing the extension.

    Regards,
    j

  8. #8
    Forum Contributor
    Join Date
    01-09-2016
    Location
    Perth Western Australia
    MS-Off Ver
    Office 365
    Posts
    257

    Re: Automatically Insert file names into a spreadsheet. Files are all in a single folder.

    Hi
    Can you please confirm the file extension required.

    Cheers

  9. #9
    Forum Contributor
    Join Date
    01-30-2011
    Location
    Boston
    MS-Off Ver
    MS 365
    Posts
    225

    Re: Automatically Insert file names into a spreadsheet. Files are all in a single folder.

    Ideally only the file names of the .txt are listed. This folder has various other extensions like PDF which should not appear in the file name list.

    Minor issue is it requests where the folder location is each run. The files are in folder C:\Desktop\Keeper - could this location be imbedded in the code and if I ever wanted to change it I could edit the path accordingly?


    Thanks for your efforts FoxSeaLady! j

  10. #10
    Forum Contributor
    Join Date
    01-09-2016
    Location
    Perth Western Australia
    MS-Off Ver
    Office 365
    Posts
    257

    Re: Automatically Insert file names into a spreadsheet. Files are all in a single folder.

    Hi

    I don't see why not I will try. Still struggling to solve .txt only files
    Trying not to give up
    Cheers

  11. #11
    Forum Contributor
    Join Date
    01-30-2011
    Location
    Boston
    MS-Off Ver
    MS 365
    Posts
    225

    Re: Automatically Insert file names into a spreadsheet. Files are all in a single folder.

    Thanks for hanging in there!

  12. #12
    Forum Contributor
    Join Date
    01-09-2016
    Location
    Perth Western Australia
    MS-Off Ver
    Office 365
    Posts
    257

    Re: Automatically Insert file names into a spreadsheet. Files are all in a single folder.

    Nearly there

  13. #13
    Forum Contributor
    Join Date
    01-09-2016
    Location
    Perth Western Australia
    MS-Off Ver
    Office 365
    Posts
    257

    Re: Automatically Insert file names into a spreadsheet. Files are all in a single folder.

    Hi

    Struggling to make this file default to one directory are not ask each time otherwise seems to meet all your criteria hen run from the default directory Keeper.
    I have essentially modified code from another project which has caused some issues.

    Hope this works despite the small inconvenience of nominating a directory each time.

    Below is the code
    Please Login or Register  to view this content.
    and attached file
    Cheers
    Attached Files Attached Files

+ 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. Moving files to a new folder by comparing file names
    By Slams in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-10-2016, 10:27 AM
  2. [SOLVED] VBA - folder/file names to spreadsheet list
    By Apelcius in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-12-2012, 12:03 PM
  3. Replies: 2
    Last Post: 11-28-2012, 04:45 PM
  4. [SOLVED] Macro to copy file names and data from each file in a folder into master spreadsheet
    By dee1989 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 07-10-2012, 05:52 AM
  5. Import all access files from a folder to a single excell file
    By wali in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-08-2009, 05:04 AM
  6. [SOLVED] Can I insert a file or folder names in Excel cells?
    By Inserting file or folder names in cells. in forum Excel General
    Replies: 1
    Last Post: 10-06-2005, 07:05 PM
  7. Replies: 2
    Last Post: 04-15-2005, 12:06 PM

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