Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 77
Default Here is a tough one!

I have a folder with a bunch of xls files. I have a separate TOTALS
file open which I need to return the sum of all the files A5 cells if
A4=YES. The file names will all be different, so I need some kind
of...open all files and if A4=YES then add it to my total on my new
sheet.

Confused - Mike
TIA

*** Sent via Developersdex http://www.developersdex.com ***
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Here is a tough one!


Private oFSO as object

Sub LoopFolders()
Dim i As Integer

Set oFSO = CreateObject("Scripting.FileSystemObject")

selectFiles "c:\MyTest"

Set oFSO = Nothing

End Sub


'---------------------------------------------------------------------------
Sub selectFiles(sPath)
'---------------------------------------------------------------------------
Dim Folder As Object
Dim Files As Object
Dim file As Object
Dim fldr

Set Folder = oFSO.GetFolder(sPath)

For Each fldr In Folder.Subfolders
selectFiles fldr.Path
Next fldr

For Each file In Folder.Files
If file.Type = "Microsoft Excel Worksheet" Then
Workbooks.Open Filename:=file.Path
With ActiveWorkbook.Worksheets(1)
If .Range("a4").Value = " YES" Then
myTotal = myTotal + .Range("A5").Value
End If
endwith
ActiveWorkbook.Close savechanges = False
End If
Next file

MsgBox myTotal

End Sub

--
HTH

Bob Phillips

"Michael Smith" wrote in message
...
I have a folder with a bunch of xls files. I have a separate TOTALS
file open which I need to return the sum of all the files A5 cells if
A4=YES. The file names will all be different, so I need some kind
of...open all files and if A4=YES then add it to my total on my new
sheet.

Confused - Mike
TIA

*** Sent via Developersdex http://www.developersdex.com ***



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 77
Default Here is a tough one!



Thanks!!

*** Sent via Developersdex http://www.developersdex.com ***
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
Please help. This is way too tough for me. Champ Excel Discussion (Misc queries) 2 November 24th 08 02:58 PM
Tough one Ben Excel Discussion (Misc queries) 3 December 11th 06 05:13 PM
Tough one: Imba Excel Discussion (Misc queries) 7 November 15th 06 08:19 PM
OK tough one ! [email protected] Excel Worksheet Functions 4 September 20th 06 09:11 PM
Tough one famdamly Excel Discussion (Misc queries) 2 February 22nd 06 04:36 PM


All times are GMT +1. The time now is 02:51 AM.

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"