Solved

Compare Excel to File Names

Posted on 2006-06-13
5
170 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 10

Accepted Solution

by:
fostejo earned 125 total points
ID: 16897670
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
ID: 16897691
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 ]
ID: 16898660
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 ]
ID: 16902430
"Micorosoft"?  Ooops.
0
 
LVL 35

Expert Comment

by:[ fanpages ]
ID: 17122249
Or not.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
using Access 8 83
Access Object Property from VBA Module in Excel 2010 2 39
How to make an ADE file by code? 11 99
VBA Replace Function - What am I missing? 3 20
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

756 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