Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 77
Default Total sum based on file name

I have one "TOTALS" worksheet where I need to display a total. I need
to cycle through a folder full of excel files, and if the name of the
file begins with "Branch" (as in "Branch19Sales.xls") I need to sum up
cell C6 on those files in my "TOTALS" worksheet.

TIA
-Mike

*** Sent via Developersdex http://www.developersdex.com ***
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Total sum based on file name

Dim fName as String, wkbk as Workbook
Dim rng as Range, tot as Double
fName = dir("C:\myfolder\*.xls")
do while fname < ""
if left(lcase(fName,6)) = "branch" then
set wkbk = Workbooks.Open("c:\myfolder\" & fname)
set rng = wkbk.Worksheets(1).Range("C6)
if isnumeric(rng) then
tot = tot + rng.value
end if
wkbk.Close Savechanges:=False
end if
fName = Dir()
Loop

activesheet.Range("B9").Value = tot

--
Regards,
Tom Ogilvy


"Michael Smith" wrote in message
...
I have one "TOTALS" worksheet where I need to display a total. I need
to cycle through a folder full of excel files, and if the name of the
file begins with "Branch" (as in "Branch19Sales.xls") I need to sum up
cell C6 on those files in my "TOTALS" worksheet.

TIA
-Mike

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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 77
Default Total sum based on file name

Tom Thank you. You are the guru.



*** Sent via Developersdex http://www.developersdex.com ***
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 77
Default Total sum based on file name

Doh, for some reason its is giving me an invalid property assignment
error on this line...it doesn't like the LCase formula I believe. What
am I missing?

If Left(LCase(fName, 6)) = "branch" Then


*** 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
assign value based on criteria and total rascal Excel Discussion (Misc queries) 1 November 22nd 09 03:38 PM
Grand total based on sub-total da Excel Discussion (Misc queries) 5 February 9th 09 07:43 PM
total amount based on selections of 1-9, 10-19 and 20-30 Pete Elbert Excel Discussion (Misc queries) 7 May 9th 07 02:22 PM
get a total based on criteria in two columns rar Excel Worksheet Functions 2 November 22nd 05 02:24 PM
total based on one constant value Phill Costello Excel Discussion (Misc queries) 3 July 28th 05 08:46 AM


All times are GMT +1. The time now is 11:03 PM.

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

About Us

"It's about Microsoft Excel"