Solved

Compare Excel to File Names

Posted on 2006-06-13
5
157 Views
Last Modified: 2010-04-30
I have imported a bunch of data into an excel worksheet that are a list of file names.  I also have a folder with a list of over 20,000 files in that folder.  I want to check if all the file names listed in my excel worksheet are present in that folder, and if they are not, I want to output the particular names into a text file.  I wanted to use the Macros of excel.
0
Comment
Question by:jmp02008
  • 3
  • 2
5 Comments
 
LVL 10

Accepted Solution

by:
fostejo earned 125 total points
Comment Utility
jmp02008,

You might want to try something like this;

1. Create a text file called 'files.csv' containing the names of all the files in the folder you need to check:
From a cmd prompt type "dir /b /on /a-d >files.csv" - this does a dir using 'B'are format, Ordered by Name and excluding Directories.

2. Open up your spreadsheet containing your current list of filenames - I'll refer to this as the 'reference' list.

3. In Explorer, double click the 'files.CSV' you've just created - being a .CSV, it should open straight into Excel (If your .CSV extension is associated with another piece of software, Open the file itself from within Excel.

4. You should now have both your original 'list of file names' (the reference list) and the 'files.CSV' open in Excel to two seperate sheets

5. In your 'reference list' sheet (on the assumption that your filenames are listed in Column 'A' starting at Row 1), enter the following formula:

=IF(ISERROR(VLOOKUP(A1,files!A1:A999,1,FALSE)),"","Exists")

This formula will attempt to look up the value in A1 against the list in files.csv sheet - if it's found the formula will show 'Exists' otherwise the cell will appear empty.

Note also, that you should alter the 'A999' value to corrospond to the actual number of filenames listed in the 'files.CSV' sheet.

6. Using your mouse, click and drag the formula just entered down Column B (use the bottom right of the cell when dragging)

Note that the VLOOKUP function expects to find exact matches - so please ensure your reference list contains filenames in the appropriate format (ie. without the file path for instance..)

Hope that helps..
0
 
LVL 10

Expert Comment

by:fostejo
Comment Utility
oops, sorry - in point (5), enther the formula in the next free column (ie. Col B probably)

cheers
0
 
LVL 35

Expert Comment

by:[ fanpages ]
Comment Utility
Please could you define where in your worksheet the list of filenames resides, that is, define the starting cell & the last cell, and specify if the filenames are fully-qualified with the full path name, or are just filenames?

Also, please indicate which folder you wish to check these files against, and where the resultant output file should be generated (and what it should be called).

Thanks for your clarification.

BFN,

fp.

(PS. The Micorosoft Excel "Topic Area" [where I normally reside] would probably be a more suitable place for this question - you may like to post a "pointer" question there [with a low, say 20, point allocation] to attract more Experts to offer suggestions)

[ http://www.experts-exchange.com/Applications/MS_Office/Excel/ ]
0
 
LVL 35

Expert Comment

by:[ fanpages ]
Comment Utility
"Micorosoft"?  Ooops.
0
 
LVL 35

Expert Comment

by:[ fanpages ]
Comment Utility
Or not.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now