Originally Posted by
Babydum
hi xld
I think ermis means that sheet 4 is blank, but that the code would replicate the
different names that appear on sheets 1 to 3, and then do the sum. I guess the names could change from week to week or something, and ermis is looking for a quick way to summarise the whole thing on sheet 4.
That's my take anyway.
Hi Taff,
Well, why didn't they say so?
Here is a first cut, dumping the formula in H10.
Const sFormulaPart1 As String = "SUMIF("
Const sFormulaPart2 As String = "!A$3:A$7,A2,"
Const sFormulaPart3 As String = "!D$3:D$7)"
Dim sFormula As String
Dim sh As Worksheet
Worksheets("Sheet4").Activate
sFormula = "="
For Each sh In ActiveWorkbook.Worksheets
If sh.Name <> ActiveSheet.Name Then
sFormula = sFormula & sFormulaPart1 & _
sh.Name & sFormulaPart2 & _
sh.Name & sFormulaPart3 & "+"
End If
Next sh
ActiveSheet.Range("H10").Formula = Left(sFormula, Len(sFormula) - 1)
End Sub