setting a formula in cell on a totals sheet using VB

  • Thread starter Thread starter JAllen3023
  • Start date Start date
J

JAllen3023

Need Help,

I have a Totals sheet with several worksheets that represent projects. The
number of worksheets(projects) will be added or deleted depending on project
completions.

What I'm trying to do is have a Macro to run that will count the number of
worksheets (since the number is not constant) and force the formula -
+ 'sheetName" !B2 + 'sheetName' !B2 - into cell B2 on the Totals sheet.
Can anyone help
 
Try this

Add two dummy sheets(empty sheets)with the name start as the first sheet
and one with the name end as the last sheet of your workbook.
this are empty sheets!!!

All worksheets between these sheets will be sum
with this formula

=SUM(start:end!B2)
 
Hello,

Sub test()
somme = 0
For Each f In ActiveWorkbook.Worksheets
somme = somme + f.Cells(2, 2) ' B2
Next
MsgBox somme
End Sub

Good luck !

BG
 
Back
Top