Data Aggregation Question...

T

Trevor Williams

Hi All

I have a workbook that pulls in datasheets from other workbooks, and renames
the datasheets Datasheet 1, Datasheet 2, etc...

I then use a bit of code to calculate the values of all sheets named
'DataSheet' onto another sheet within the workbook.

My 'calculation' code is below, but I'm wondering if this is the best way to
do it, or whether there is a worksheet formula I should use? (Indirect?)

Thanks in advance.

Trevor Williams

Private Sub CalcAllData()
Dim sh As Worksheet
Range("A1:R57").ClearContents
For Each sh In ActiveWorkbook.Sheets
If sh.Name Like "Datasheet*" Then
For x = 1 To 57
For y = 1 To 18
ActiveSheet.Cells(x, y) = ActiveSheet.Cells(x, y).Value +
sh.Cells(x, y).Value
Next
Next
End If
Next
End Sub
 
B

Bernie Deitrick

Put all your data sheets between two blank sheets, named First and Last, then use this formula in
cell A1 of your activesheet.

=SUM(First:Last!A1)

and copy out to A1:R57.

HTH,
Bernie
MS Excel MVP
 
T

Trevor Williams

Excellent Bernie, thanks very much.

Bernie Deitrick said:
Put all your data sheets between two blank sheets, named First and Last, then use this formula in
cell A1 of your activesheet.

=SUM(First:Last!A1)

and copy out to A1:R57.

HTH,
Bernie
MS Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top