I'm still unclear about when to add and when to copy, but this is what I have so far.
Open the attached workbook, open Book2 and then run the sub Test
' in a normal code module in Workbook 1 (the one that doesn't change)
Sub test()
Dim Book1 As Workbook, Book2 As Workbook
Dim Sh1 As Worksheet, Sh2 As Worksheet
Dim Data1 As Variant, Data2 As Variant
Dim i As Long, j As Long
Dim CopyFlag As Boolean, AddFlag As Boolean
Set Book1 = ThisWorkbook
For Each Book2 In Application.Workbooks
If Book2.Windows(1).Visible And Book2.Name <> Book1.Name Then
If MsgBox("Update " & Book2.Name & "?", vbYesNo) = vbYes Then Exit For
End If
Next Book2
If Book2 Is Nothing Then
MsgBox "goodbye"
Else
Application.DisplayAlerts = False
For Each Sh1 In Book1.Worksheets
If SheetNamedExists(Book2, Sh1.Name) Then
Set Sh2 = Book2.Worksheets(Sh1.Name)
CopyFlag = (0 < Val(Sh1.Range("C3").Value)) Or (0 < Val(Sh1.Range("C8").Value))
With Sh2
If (IsNumeric(.Range("C3")) And (Val(.Range("C3").Value) = 0)) Or (.Range("C3") = vbNullString) Then
CopyFlag = CopyFlag And True
Else
CopyFlag = CopyFlag _
And (IsNumeric(.Range("C8")) And (Val(.Range("C8").Value) = 0)) Or (.Range("C8") = vbNullString)
End If
End With
With Sh1
AddFlag = (1 < Val(.Range("C3").Value)) Or (1 < Val(.Range("C8").Value))
End With
With Sh2
AddFlag = AddFlag And ((1 < Val(.Range("C3").Value)) Or (1 < Val(.Range("C8").Value)))
End With
AddFlag = AddFlag And Not ((Sh1.Range("C3").Value = Sh2.Range("C3").Value) And (Sh1.Range("C8").Value = Sh2.Range("C8").Value))
If AddFlag Then
MsgBox "add" & Sh1.Name
Data1 = Sh1.Range("D2:AH31").Value
With Sh1.Range("D2:AH31")
Data2 = .Value
For i = 1 To .Rows.Count
For j = 1 To .Columns.Count
If IsNumeric(Data1(i, j)) And IsNumeric(Data2(i, j)) Then
Data2(i, j) = Data1(i, j) + Data2(i, j)
End If
Next j
Next i
.Value = Data2
End With
ElseIf CopyFlag Then
MsgBox "copy " & Sh1.Name
Sh1.Copy before:=Sh2
ActiveSheet.Name = Chr(5)
Sh2.Delete
Book2.Sheets(Chr(5)).Name = Sh1.Name
Else
MsgBox "do nothing with " & Sh1.Name
End If
End If
Next Sh1
End If
Application.DisplayAlerts = True
End Sub
Function SheetNamedExists(wb As Workbook, SheetName As String) As Boolean
On Error Resume Next
SheetNamedExists = (LCase(wb.Worksheets(SheetName).Name) = LCase(SheetName))
On Error GoTo 0
End Function