PC Review


Reply
Thread Tools Rate Thread

Aggregating data from various file in one.

 
 
lt
Guest
Posts: n/a
 
      16th Oct 2006
I have a set of data files with the same format that I would like to
add up in a summary excel file. So for example, I would like to add
all the A1 cells of all the sheet1 worksheets of all data files to cell
A1 of the sheet1 worksheet of the summary file. How can I do it?
Thanks in advance for any help.

 
Reply With Quote
 
 
 
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      16th Oct 2006
do you have a list of data files. Or are all the data files in a single
directory with no other files. Or are they all in a single directory, with
other files, but they all have a common unique element in their name?

sub ProcessWorkbooks()
Dim cell as Range, sPath as String, sName as String
Dim bk as Workbook, v as Variant
set cell = thisworkbook.Worksheets("sheet1").Range("A1")
spath = "C:\Myfiles\"
sname = dir(sPath & "*.xls")
do while sName <> ""
set bk = workbook.Open(sPath & sName)
v = bk.worksheets("Sheet1").Range("A1")
bk.close Savechanges:=False
if isnumeric(v) then
cell = cell + v
end if
sName = dir()
Loop
End sub

would be the approach for all the *.xls files in a single directory.

--
Regards,
Tom Ogilvy


"lt" wrote:

> I have a set of data files with the same format that I would like to
> add up in a summary excel file. So for example, I would like to add
> all the A1 cells of all the sheet1 worksheets of all data files to cell
> A1 of the sheet1 worksheet of the summary file. How can I do it?
> Thanks in advance for any help.
>
>

 
Reply With Quote
 
lt
Guest
Posts: n/a
 
      16th Oct 2006
Thanks so much Tom!

Tom Ogilvy wrote:
> do you have a list of data files. Or are all the data files in a single
> directory with no other files. Or are they all in a single directory, with
> other files, but they all have a common unique element in their name?
>
> sub ProcessWorkbooks()
> Dim cell as Range, sPath as String, sName as String
> Dim bk as Workbook, v as Variant
> set cell = thisworkbook.Worksheets("sheet1").Range("A1")
> spath = "C:\Myfiles\"
> sname = dir(sPath & "*.xls")
> do while sName <> ""
> set bk = workbook.Open(sPath & sName)
> v = bk.worksheets("Sheet1").Range("A1")
> bk.close Savechanges:=False
> if isnumeric(v) then
> cell = cell + v
> end if
> sName = dir()
> Loop
> End sub
>
> would be the approach for all the *.xls files in a single directory.
>
> --
> Regards,
> Tom Ogilvy
>
>
> "lt" wrote:
>
> > I have a set of data files with the same format that I would like to
> > add up in a summary excel file. So for example, I would like to add
> > all the A1 cells of all the sheet1 worksheets of all data files to cell
> > A1 of the sheet1 worksheet of the summary file. How can I do it?
> > Thanks in advance for any help.
> >
> >


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Aggregating Data randlesc Microsoft Access Queries 3 1st Mar 2010 09:15 PM
Aggregating data for a chart eab Microsoft Excel Charting 0 11th Feb 2009 04:56 PM
aggregating rows of data Jill Microsoft Access 1 21st Jun 2008 01:41 AM
Aggregating data pilotdata Microsoft Excel Misc 6 9th Nov 2005 02:28 PM
Aggregating data =?Utf-8?B?SlZMaW4=?= Microsoft Excel Programming 5 8th Mar 2005 03:09 PM


Features
 

Advertising
 

Newsgroups
 


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