Summing same cell in mutiple Sheets
Tom,
Your example doesn't seem to work for me (XL2000)
Regards,
KL
"Tom Ogilvy" wrote in message
...
You may want to look in help at 3D ranges (which are what Bob and KL
actually use). If you put in two dummy sheets (keep the sheets blank)
Start
Last
as example, and set up your summary sheet after Last, then in the summary
sheet you can put (example cell B2)
=Start!Last!B2
then select this cell and drag fill down and across.
Now any sheets ented (in the tab order) between Start and End will be
included in the sum. this should be much more efficient and automatic
than
running code each time the sheets change. Also, you can drag sheets out
of
and between these two sheets if you want to do some "what if" type
analysis
as an example.
--
Regards,
Tom Ogilvy
"Chaplain Doug" wrote in message
...
I did just that and all works well. God bless you both!
"KL" wrote:
Opps! Thanks Bob, you are probably right - entering a formula is a more
natural solution rather than just a value.
So, Doug, if you still want the cell-by-cell sum then you can just
change
the following line in my code:
c.Value = Evaluate(MyFormula)
to:
c.Formula = MyFormula
Regards,
KL
"Bob Phillips" wrote in message
...
Doug,
Here is an alternative that puts a formula in cell A1 on the Wrap
sheet.
This all accumulates into 1 cell, as against KL's accumulating into a
mapped
range, and by using a formula, any future changes are reflected
Worksheets("Wrap").Range("A1").Formula = _
"=SUM('" & Worksheets(1).Name & ":" & _
Worksheets(Worksheets.Count - 1).Name & "'!A1:A10)"
--
HTH
RP
(remove nothere from the email address if mailing direct)
"KL" wrote in message
...
Hi,
Try the below code
Regards,
KL
Sub test()
With ThisWorkbook
LastSheet = .Sheets.Count - 1
For Each c In .Sheets("Wrap").Range("A1:A10")
MyFormula = "=SUM('" & Sheets(1).Name & ":" & _
Sheets(LastSheet).Name & "'!" & c.Address & ")"
c.Value = Evaluate(MyFormula)
Next
End With
End Sub
"Chaplain Doug" wrote in
message
...
Excel 2002-2003. I build a workbook programmatically. The
workbook
has
mutiple sheets (and I know how many programmatically). I add a
last
sheet
that I want to be a "wrap" of all the other sheets. How do I
programmatically set a cell in the last sheet to be the sum of the
same
cell
in all of the other sheets? Also, is there a way to do this
programmatically
for a range of cells rather than cell by cell? Thanks for the
help.
God
bless.
|