Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

Can I export file names to excel?

I need to cross check a list of 2000 drawing files against the list of required drawings to make sure that everything is there. Instead of checking them one by one I was hoping I could somehow create a list of all the drawings (files) in the folder in excel automatically so that I can do a vlookup or something like that.

1 Answer

Relevance
  • Greg G
    Lv 7
    8 years ago
    Favorite Answer

    Here's a macro I've had saved for a long time. This will ask you for the directory you want your files from, and import all the filenames. Just select the cell you want the list to begin and run the macro.

    Open the VBE with ALT + F11, then Insert >> Module

    Copy this code and paste it into the module:

    Sub Hyperlink_List()

    Dim par, sfil As String

    Dim r As Range

    par = Application.InputBox("Enter Directory")

    sfil = Dir(par & "*.*", vbDirectory)

    Set r = ActiveCell

    Do Until sfil = ""

    If sfil = "." Or sfil = ".." Then GoTo skipit

    r = sfil

    ActiveCell.Hyperlinks.Add r, par & sfil

    Set r = r.Offset(1)

    skipit:

    sfil = Dir$

    Loop

    End Sub

    Close the VBE and run the macro. Enter the path to the folder and your filenames will be added and hyperlinked so they can be opened from within Excel.

Still have questions? Get your answers by asking now.