Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Find files and sum a value inside sheets (VBA)
When i use this command button in a pc wint XP and Excel 2003 in English this
query works, when i try in my computer with XP in Portuguese and Excel 2003 in English the results is always "No files found." Anyone can help-me? ------------------------------------------------------------------------------------- Sub SearchForFiles() 'Declare a variable to act as a generic counter Dim lngCount As Long Application.ScreenUpdating = False ' turn off the screen updating 'Use a With...End With block to reference the 'FileSearch object Set fs = Application.FileSearch With fs 'Clear all the parameters of the previous searches. 'This method doesn't clear the LookIn property or 'the SearchFolders collection. .NewSearch 'Setting the FileType property clears the 'FileTypes collection and sets the first 'item in the collection to the file type 'defined by the FileType property. .FileType = msoFileTypeExcelWorkbooks .Filename = "VW*" 'Set up the search to look in all subfolders on the C:\ drive. .LookIn = "c:\VW" .SearchSubFolders = True 'Execute the search and test to see if any files 'were found. valor = .Execute If valor 0 Then 'Display the number of files found. MsgBox "Files found: " & .FoundFiles.Count 'Loop through the list of found files and 'display the path of each one in a message box. For lngCount = 1 To .FoundFiles.Count Workbooks.Open .FoundFiles.Item(lngCount) valor = valor + Worksheets("Sheet1").Range("I96").Value ActiveWorkbook.Close Next lngCount Else MsgBox "No files found." End If End With Application.ScreenUpdating = True ' turn on the screen updating Worksheets("Sheet1").Range("C6").Value = valor End Sub Private Sub CommandButton1_Click() Call SearchForFiles End Sub Private Sub s_Click() End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How to find the formula inside #REF error | Excel Discussion (Misc queries) | |||
search folder/directory for a phrase inside excel files | Excel Discussion (Misc queries) | |||
find and replace inside comments? | Excel Discussion (Misc queries) | |||
I would like to print the titles of files inside a folder. | Excel Worksheet Functions | |||
rename folder o files with value from inside each wbk | Excel Programming |