Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 184
Default Add Cells Using Multiple Files in One Folder

I have a folder with about 20 excel files in it that I want to add all
numbers in A1 of the 20 files to a new excel file. What is the best way to
do this? I have a bunch of cells I want to do this with.

Thank you
Jeremy

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default Add Cells Using Multiple Files in One Folder

With 5 or less files, I would use a single formula. With more, I would use a
helper column:

In A1 thru A20 enter formulas like:

='C:\Temp\[visit me.xls]Sheet1'!$A$1
='C:\Temp\[second.xls]Sheet1'!$A$1
='C:\Temp\[third.xls]Sheet1'!$A$1

and then =SUM(A1:A20)
--
Gary''s Student - gsnu200795


"Jeremy" wrote:

I have a folder with about 20 excel files in it that I want to add all
numbers in A1 of the 20 files to a new excel file. What is the best way to
do this? I have a bunch of cells I want to do this with.

Thank you
Jeremy

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9,101
Default Add Cells Using Multiple Files in One Folder

Sub gettotals()

Folder = "C:\temp\"
SumCells = Array("A1", "B2", "C3")

'open newbook
Set newbk = Workbooks.Add
Set newsht = newbk.Sheets("Sheet1")
newsht.Name = "Summary"
GoTo mend
FName = Dir(Folder & "*.xls")
Do While FName < ""
Set OldBk = Workbooks.Open(Filename:=Folder & FName)
Set OldSht = OldBk.Sheets("Sheet1")

For Each cell In SumCells
If IsNumeric(OldSht.Range(cell).Value) Then
newsht.Range(cell).Value = newsht.Range(cell).Value + _
OldSht.Range(cell).Value
End If
Next cell
OldBk.Close savechanges:=False
FName = Dir()
Loop
mend:
fileSaveName = Application.GetSaveAsFilename( _
fileFilter:="Excel Files (*.xls), *.xls")
newbk.SaveAs Filename:=fileSaveName
ActiveWorkbook.Close savechanges:=True

End Sub

"Jeremy" wrote:

I have a folder with about 20 excel files in it that I want to add all
numbers in A1 of the 20 files to a new excel file. What is the best way to
do this? I have a bunch of cells I want to do this with.

Thank you
Jeremy

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
Linking certain cells from Multiple files in a folder onto a summa lee Excel Worksheet Functions 1 June 4th 08 03:19 PM
Extract cell data from multiple files in one folder smonsmo Excel Discussion (Misc queries) 3 August 17th 07 11:16 PM
Macro help - Moving 2 cells from 100 separate files into new folder Steven Excel Discussion (Misc queries) 7 July 10th 07 07:47 PM
Copying Cells from CSV files in folder into one worksheet [email protected] Excel Discussion (Misc queries) 1 June 23rd 06 09:23 PM
Linking cells to files in a folder beginnerExceluser New Users to Excel 1 October 4th 05 06:41 AM


All times are GMT +1. The time now is 10:54 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"