Time For Getting Data - Search For 445 Files In Folders On Specific Path

Jan 1, 2013

I build a VBA that search for 445 files in folders on specific path.

The code opens each file, take each time the same 31 rows, filter them and paste in the main data base file and then close the origin file.

So, for 445 files it takes about 6:30 minutes.

View 4 Replies


ADVERTISEMENT

Opening Excel Files In File Path Which Includes Folders?

Nov 7, 2007

I am trying to open excel files in a file path which includes folders which also have excel folders i wish to open there are quite a few.

At the moment i am working with this code but it fails to open excel files which are within the folders in the specified file path. Its fine for excel workbooks in the folder specified by file path.

This is the code

Sub RunCodeOnAllXLSFiles()
Dim lCount As Long
Dim wbResults As Workbook

[Code].....

View 9 Replies View Related

Consolidate Data From Multiple Files Within Folders & Sub Folders

Aug 16, 2009

I have managed to get this far - I have put together a macro (from different threads on this site) that opens closed workbooks, copies data in one of the sheets (same sheet in each of 28 books), and pastes the data it into a master book sheet, each paste starting below the last. So that bit is working. The first bit of help I need is a line of code that will make the macro loop through a number of sub folders in a main folder. My code at the moment works as long as I specify a path that ends with the name of one subfolder, and it only loops through this subfolder. I would like the path to end at the folder that holds all the subfolders ('Workbooks' in the path below), and then add some code that tells it to apply the macro to all subfolders in this folder, so it loops through them all.

The second issue is that after the macro goes to the closed book(s), copies the data in there and pastes it into the master sheet (into columns E:FG), I then need it to go back to the workbook it just copied from, go the same sheet, to three specific cells on that sheet (FH1:FH3), copy the content, go back to the master sheet, and now repeatedly paste the content (values only and transposed) of these three cells into three cells (in columns B:D, with row number being dependent on what rows the first lot of data was copied into) next to every row it just previously pasted in for me. When it loops to the next workbook, it needs to do the same, and the three cells will have different content than the ones in the previous workbook paste.

I dont know how to define the range it needs to paste into the second time. I tried using the definition I used for the first paste (MCDrow), to tell it that it is the same rows, just different columns, but this is not working.

Here is what I have so far, which does the first part of what I need, except for needing a way to have it loop through all subfolder in the 'Workbooks' folder (at the moment it lists Barwon South West as a subfolder in that path, but I actually have multiple subfolders, not all called Barwon South (all different names) that it needs to loop through and do both the first and the second paste for. I have taken out the code I was trying to use to do the second paste, as this was not working and the code is pretty messy as it is (I sort of bumble along, being so new, and I know the code is not very clean or efficient!).

Can someone help me put in the few lines I need to loop through all my subfolders (if you give me an example I can probably extrapolate), but to get you started, three of the subfolders are Barwon South West, Eastern Region and Gippsland. And can someone help me put in the code that will do the second paste for each workbook?

Sub Click2()

Application. ScreenUpdating = True
Dim MCDrow As Long
'Dim SubFolders As String
MCDrow = ThisWorkbook.Sheets("Client Data").Range("A65536").End(xlUp).Row

Fpath = "Q:Clinical ServicesCS Statewide DatabaseWorkbooksBarwon South West" ' change to your directory
'SubFolders = True
Fname = Dir(Fpath & "*.xls")
Do While Fname <> ""

ThisWorkbook.Sheets("Client Data").Unprotect

Workbooks.Open Fpath & Fname
Worksheets("Client Data").Activate
Worksheets("Client Data").Unprotect

View 6 Replies View Related

Search Folders And Create Hyperlinks To Files

Feb 18, 2009

I have a list of file names sans extension in column A. I want to search a folder I specify and if file is found create a hyperlink to said file either in a new cell or in column A.

The code I have does the search fine, but its hyperlinking is offset and I can’t get it to match the link to the file name.

Also it breaks if it can not find the file.

Here is the code...

View 9 Replies View Related

Search Folders & Subfolders For Files By Date Modified & Move/Copy Them

Aug 5, 2009

I'm trying to make a macro that will search a folder and move all files from 2008 into another folder. So far it can do this, but what i need is for it to search subfolders also. At this point it moves all files from the main folder, but nothing from the subfolders.

Option Explicit
' Reference site [url]

Sub Copy_and_Rename_To_New_Folder()

Dim objFSO As FileSystemObject
Dim objFolder As Folder
Dim PathExists As Boolean
Dim objFile As File
Dim SrcFolder As String
Dim DestFolder As String
Dim x, Counter As Integer, Overwrite As String, strNewFileName As String
Dim strName As String, strMid As String, strExt As String
Dim LastModYear

View 5 Replies View Related

Use Excel VBA To Copy Multiple Files From Different Source Folders To Different Folders?

Jun 12, 2014

I need to back up files, which may be excel or MSword, by copying them from different directories, say C: to the backup directory, say X:. any vba to backup the files? I expect the vba can copy all file listed in column A.

E.g. C: est1File1.xls or C: est2File2.doc, and then pasted to the directory in column B. e.g. X:BackupFolder1 or X:BackupFolder2.

View 1 Replies View Related

Search Folders And Sub Folders For Worksheet And Return Range?

Jul 8, 2013

macro and I think this has me on my way; however, I do not understand the code and I am having difficulty modifying it. It returns the path in cell $A1 of my workbook, but I get reference errors in $B1:$L1.

I would like for the code to start entering the values in row 2 of my current worksheet. Row 1 I want to make a header row. The first column I like having the file path. Can the path be changed to a hyperlink? I would then like for it to return the values in $AP1:$BC1 to $B1:$O1 of my current workbook.

View 4 Replies View Related

Open All Excel Files In Directory - Code Doesn't Work For One Specific Path

Feb 8, 2014

I have my code here:

VB:
Sub openfiles()Dim Path As String
Dim ExcelFile As String
' Path = GetFolder("C:UsersKinteshDesktop")
Path = "C:UsersKinteshDesktopVBA programmingMaps"
ExcelFile = Dir(Path & "*.xls")

[Code] ....

NextCode:
GetFolder = sitem
Set fldr = Nothing
End Function

My problem is that the code all actually works (including the function and when I use the commented part), but pointing to this one specific directory (the one I'm using right now), literally nothing happens.

View 6 Replies View Related

Copy And Rename Files In VBA By Searching Multiple Folders For Files?

Jan 4, 2014

how I can loop through folders to select files starting with a certain word and copy all of them to a different folder and rename them. The folder structure is given below

Company 1(parent folder)
North South East(sub folder) West(sub folder)
Jan Feb Mar.... Dec Jan Feb Mar.... Dec Jan Feb Mar.... Dec Jan Feb Mar.... Dec

In the above structure, the files are present inside each folders Jan, feb...Dec under the regions North, South East n west. note that I have to select files starting with "Sales" and copy them into a new folder(say results) and rename copied files as Sales1.xls, Sales2.xls etc. (Files are not present in the folder company1, north, south, east and east.)

View 1 Replies View Related

Search For Files Containing Specific Text In Cell

Jan 2, 2009

I cannot find Excel files that contain specific strings. For example, if I create a new file, and in the first cell type in "123456". Then save the file to the folder c:Temp Then in Windows Explorer, right-click on C:Temp and select "Search . . ." Then under "A word or phrase in the file", type in: 123456
It will NOT find the file! It will find a txt file or a doc file, but not xls files.

I thought maybe it fails because that is a number. But I have hundreds of Excel files with Integer numbers stored in "General" format cells and I desperately need to be able to search them to see which files contain certain numbers. It all started with some files that were sent to me - they work PERFECTLY for searching cells for numbers. So strange - yet if I open the file then save it . . . no changes or edits at all, just Open and Save. . . then the search fails for all numbers in that file. This is so perplexing that I have placed 2 zip Sample files on my website for you to Download: http://www.infocellar.com/Samples.zip

Unzip the two files to any folder. One is named "Sample-Works.xls" - Then do a Windows Search for any number in the file, here is one to try that is in the two files: 174026 And it will list "Sample-Works.xls" but it will NOT list "Sample-Fails.xls", even though BOTH FILES ARE IDENTICAL! I copied the same file twice and then named them. The only difference is that I opened the file Sample-Fails.xls and then immediately Saved it, which as I stated earlier, makes it fail all Searches from that point forward.

View 5 Replies View Related

Copy Folders To New Destination Based On Path In Cell

Sep 27, 2013

I have this code that copies existing folders to a new destination path. How do I change the code so that the From path and To path is based on cell value rather than writing it into the code?

Code:
Sub Copy_Folders()Set Fobj = CreateObject("Scripting.FileSystemObject")
Fobj.CopyFolder "C:UsersHengDocuments1243-01234photos", "C:UsersHengDocumentsCasework1243-01234photos"
End Sub

View 9 Replies View Related

How To Change External Data Path For Mdb Files

Apr 13, 2009

to fix a .xls file that wasn't created by me.

In order to do that I need to change the path of an External Data that is an access 2003 file (.mdb file).

The only way that I imagine it is possible is to select a cell that is an adress for the query result, than click on properties and change it selecting the new path of file (the path moves depending on the user of the .xls).

View 9 Replies View Related

Creating Folders On Shared Drive - Path File Too Long

Dec 5, 2011

I've made a macro that would create some folders on a shared drive.

there is an issue if the path i want to create is too long.

I get this error.

Uploaded with ImageShack.us

is there anything we can do to pass this or any solution for it?

View 5 Replies View Related

Macro To Search For Specific TXT In Directory Of Approx 1000 XLS Files

Oct 3, 2012

Need macro to search approx 1000+ xls files in folder/directory for common text string "see reference" and then output the file number which is located in cell A1 to new spreadsheet for each file the text "see reference" is found.

View 2 Replies View Related

Macro To Copy Folders To Path Of Open Workbook Based On Cell Values

Aug 3, 2014

I have an Excel sheet that contains a few thousand folder paths in the first column. The first few cells in the column look similar to below.

C:UsersNameDesktopFolder Copy12010360
C:UsersNameDesktopFolder Copy12010361
C:UsersNameDesktopFolder Copy12010362
C:UsersNameDesktopFolder Copy12010363
C:UsersNameDesktopFolder Copy12010364
C:UsersNameDesktopFolder Copy12010365

I am trying to create a macro that will copy any folders that exist in any of the paths listed in the first column. The folders should be copied to the path of the open workbook containing the macro. Below is the macro I have currently, much of which was taken from information I found in this thread [URL]....

VB:

Sub wrapper3()
x = 1
Set fs = CreateObject("Scripting.FileSystemObject")
While Sheets("Air").Cells(x, 1) <> ""
v = InStrRev(Sheets("Air").Cells(x, 1), "")
dest = ActiveWorkbook.Path & Mid(Sheets("Air").Cells(x, 1), v, 99)

[Code]...

This code seems to work fine if all of the folders exist to be copied. My problem is that some do not and it is creating a "Path Not Found" error for which I need a fix. If the folder doesn't exist at the path nothing should be copied and the next path can be evaluated.

View 2 Replies View Related

VBA Folder Path - Extract Some Data From Specific Sheet

May 7, 2012

I am using some code to loop through a folder and extract some data from a specific sheet.

Now say a user moves the file to another folder etc... The macro will pull up an error, now is there a way i can have it dynamic linked to the spreadsheet so no matter what folder it gets moved to,

My folder path will adjust to that or need to take another route?

View 2 Replies View Related

Files Within Sub Folders

May 29, 2007

I am using the code below to list all files within a specific folder however I need to know about ALL the files within the underlying sub folders (of which there are many).

I have tried wildcards when declaring the folder but it does not work.

Sub List_Files()

Dim fsoObj As Object 'Scripting.FileSystemObject
Dim fsoMapp As Object 'Scripting.Folder
Dim fsoFil As Object 'Scripting.File
Dim sFolder As String
Dim i As Long
Dim filtype As String
sFolder = "V:T-ASSETAsset ScotlandNetwork Capacity Section1 Business Plan"

Set fsoObj = CreateObject("Scripting.FileSystemObject")

'Set fsoObj = New Scripting.FileSystemObject........................

View 9 Replies View Related

VBA Saving PDF Files Into Folders

Sep 29, 2013

I have this code that generates excel pages as pdf files, but I can't get it to save it in its individual folders. For example, I have the sheet name as Brian Lin, I want to save the pdf into the folder called Brian Lin, then if I have the sheet name as Lilly Tran, the pdf should save into the folder called Lilly Tran. Here's my code. The code is one step short of what I want it to do, it saves in the folder right before the name folders.

Code:

Sub Macro1()
Dim wsh As Worksheet, vWshs
Dim sFolderName As String, set_Path As String, name As String, hwas As String, sname As String, swsname As String
vWshs = Array("Rates", "Inputs")
set_Path = "C:UsersJonathanDesktopFaFundInvoices" & hwas & ""

[Code]...

View 4 Replies View Related

Finding Files In Folders

Jun 12, 2008

I need to design code that can check to make sure a specific file is found before it executes.

Our files are all going to start with the same words followed by the date

ex. Name 10-2-1998

I want the code to be dynamic and be able to check in the folder that the current excel sheet is in for the file i need and then have it ready for use in my macro.

View 9 Replies View Related

List Files And Folders

Jun 19, 2008

I have a folder that has a bunch of other folders in it, each containing many files. Is there an easy way to get a file directory into excel, so that I now would have a spreadsheet that tells me what all the folders are and what files are in each one?

short example: main folder = mystuff
subfolder1 = my pix, contains pic1 and pic2
subfolder2 = otherstuff, contains otherstuff1 and otherstuff2

Can excel find these things and give me a list indicating that the 'mystuff' folder contains these two folders, and also list the two files under each folder?

View 6 Replies View Related

How To Assign Macros On All Files In Sub Folders

Apr 13, 2014

I have my main directory C:Perinatal Within that directory I have folders that contain results for each medical conditions (see attachments)

Within each subdirectory are 6 workbooks with (untidy) data results, all the same format just different numbers for each analysis. I want my MAIN_MACRO to loop through every single .xls file in the C:Perinatal, cleaning up the data of all files, and then saving.

I can use the following code to cycle through each folder one at a time, however, I'd like to loop through every subdirectory of

C:Perinatal instead to speed up the process, rather than having to change the path for each subfolder (e.g. C:PerinatalCANCERALL). Is this possible?

If this isn't possible how can I create a 'MyPaths' list and loop through all those directories.

[Code] ......

Attached Images :

folders.jpg‎
CANCERJPG.jpg‎

View 1 Replies View Related

Moving Files From Folder And Sub-folders

Jan 29, 2014

I need to move all the "Excel" files which are available in Folder and also the Subfolders from this location.

I need all the Excel files.

I found a code which is able to move only from Folder but not from the Subfolder.

HTML Code: 

Sub Move_Certain_Files_To_New_Folder()
'This example move all Excel files from FromPath to ToPath.
'Note: It will create the folder ToPath for you with a date-time stamp
Dim FSO As Object
Dim FromPath As String
Dim ToPath As String
Dim FileExt As String
Dim FNames As String

[code].....

View 3 Replies View Related

Loop Through Files In Dated Folders

Nov 30, 2008

each folder is named by date, for example a folder name may be 04-01-2008. Within each folder there is one xls file named daily.xls.
(this never changes)
In date order from the folder name, I need to open each daily.xls run my code, then close daily.xls and then open the next one etc until there are no more.

example path is C:4-01-2008daily.xls

View 9 Replies View Related

Create Folders & Copy Files To It

Jun 26, 2007

I need to create a macro that will allow the user to create a directory based on a template directory, with all directory paths/ names stored in workbook cells:

1) Create a new directory (name/path specified in workbook)
2) Go to a template directory & copy the entire directory, subdirectories & all files
3) Paste them into the new directory
4) Save a copy of the workbook into the specified location from (3)

Example:
X:Templates
-copy all to-
X:Projects(Value specified in workbook cell)

View 3 Replies View Related

Breakdown Of All Folders & Files In Directory

Sep 12, 2007

I am trying to specify all files and folders in a directory and the only help I found was the following thread: Create Index Of Files In Folder That works really well but, what I need is to specify all the folders and all the files under a directory, does any of you awsome hacks have an idea of how I can enhance the macro if the thread posted above?

View 3 Replies View Related

Hyperlink To Files Including Sub Folders

Aug 5, 2008

I am currently using the following code found in this post: Create Index Of Files In Folder

I am not familiar with VB at all. All I want to do is be able to index the sub-directories contained within the main directory. Is there a simple way to edit this code? ...

View 9 Replies View Related

Renaming Files In Infinite Number Of Sub Folders?

Feb 25, 2014

I have written a procedure that renames excel files within a folder based on certain words being in the title. It works for the files in the first lot of subfolders but I am trying to work out how to get it to rename all files in all subfolders regardless of the level.

I've seen similar things done using recursive subs but I have been trying to convert some of the sample codes I've found online to fit my situation and am not having much luck.

how to manipulate my code into something like a recursive procedure or anything else that will do what I want.

Here is my code.

[Code] .....

View 2 Replies View Related

How To Traverse Folders And Files On SharePoint With Excel VBA

Mar 9, 2011

how to traverse all files in SharePoint folders using Excel VBA and have not come across an answer I could use because, by configuration design, I cannot map a SharePoint URL to a drive letter.

Here it is:

Sub SPDir()
Dim wb As Workbook
Dim dummyFile As String
'
' The file specified by dummyFile must reside in SharePoint in order to use SharedWorkspace
' The way the code is set up, the path and filename in dummyFile should NOT substitute %20 instead of spaces
' There is logic later to ignore dummyFile on output
' Substitute your own dummy file name below

[code].....

View 9 Replies View Related

Write Script Which Returns All Files And Folders?

Nov 2, 2012

I need to write a script which returns all files and folders. The script should also work on a Mac pcs. The "Windows" script works without any problems but I have real problems with the Mac script:

Code:
Public Sub List_Files_Mac()
Dim sDir As String
Dim sFile As String

[Code]...

This script doesn't return the folders and long filenames are truncated.

View 4 Replies View Related

VBA Macro To Loop Through Folders And Select Files With Certain Criteria

Feb 6, 2014

I'm looking to create a macro that does the following:

- Loops through a folder structure
- Opens a specific subfolder within each folder based on name (i.e. "*Financials*")
- Opens a specific file within that subfolder "*Financials*" based on both most recently modified a naming criteria (i.e. "*Model*")
- Performs an action on that file (a macro created elsewhere that I assume I can call here)
- Closes that file, and moves on to the next file matching the criteria above

As a self-diagnosed VBA novice, I'm having trouble adapting code found in various forums for my specific project.

I've found examples that address aspects of my desired macro or do similar things, but I can't figure out how to put them together.

Open most recent file:

[Code] .....

Loop through folders and subfolders and print all files:

[Code] ....

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved