VBA code looking through files

nathan663

Board Regular
Joined
Dec 3, 2008
Messages
153
Sub Hip_File_Open()
'
' Hip_File_Open Macro
fldr = "Q:\Workforce Planning and Allocation\HIP Files"
d = Dir(fldr & "*.xls") 'looks at all xls files in folder
Do While d <> "" 'd is a string containing the file name

d = Dir
Loop

End Sub


In the worksheet this macro is run from there is a list of numbers in column A. When the macro runs i need the macro to look through the file shown above looking for the number in cell A1. It will look through all the files, and if it finds the number it is looking for it will return the title of the workbook it found the number in. If it does not find the number in any of the work books it will bring back the result (not found)

What code is needed to do this?

Thanks
 

Some videos you may like

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

xld

Banned
Joined
Feb 8, 2003
Messages
5,378
Do you mean search all cells in the workbookms foer that number, or for that number to be part of the filename?
 

nathan663

Board Regular
Joined
Dec 3, 2008
Messages
153
sorry they are actually workbooks arent they. there is only one sheet i need to look through in each work book. so to make it clearer there are around 20 workbooks in each folder, that i need to search through for a certain number each time.


can any one help?
 

Subscribe on YouTube

Watch MrExcel Video

Forum statistics

Threads
1,106,533
Messages
5,511,887
Members
408,867
Latest member
Ranjeet yamgekar

This Week's Hot Topics

  • Turn fraction around
    Hello I need to turn a fraction around, for example I have 1/3 but I need to present as 3/1
  • TIme Clock record reformatting to ???
    Hello All, I'd like some help formatting this (Tbl-A)(Loaded via Power Query) [ATTACH type="full" width="511px" alt="PQdata.png"]22252[/ATTACH]...
  • TextBox Match
    hi, I am having a few issues with my code below, what I need it to do is when they enter a value in textbox8 (QTY) either 1,2 or 3 the 3 textboxes...
  • Using Large function based on Multiple Criteria
    Hello, I can't seem to get a Large formula to work based on two criteria's. I can easily get a oldest value based one value, but I'm struggling...
  • Can you check my code please
    Hi, Im going round in circles with a Compil Error End With Without With Here is the code [CODE=rich] Private Sub...
  • Combining 2 pivot tables into 1 chart
    Hello everyone, My question sounds simple but I do not know the answer. I have 2 pivot tables and 2 charts that go with this. However I want to...
Top