Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to find the formula inside #REF error #REF error Excel Discussion (Misc queries) 5 January 17th 09 03:05 PM
search folder/directory for a phrase inside excel files pwrichcreek Excel Discussion (Misc queries) 5 August 11th 08 09:39 PM
find and replace inside comments? Knox Excel Discussion (Misc queries) 3 August 31st 07 05:12 PM
I would like to print the titles of files inside a folder. onenevadadollar Excel Worksheet Functions 1 November 17th 05 12:26 AM
rename folder o files with value from inside each wbk Max Bialystock Excel Programming 2 January 2nd 04 09:24 AM


All times are GMT +1. The time now is 01:18 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"