I can't figure out a way to do that just in a formula. Here's how it could be done with a macro:
Option Explicit
Public Sub SubractTest()
With Sheets("Sheet1")
SubtractArrays .Range("G3:L6"), .Range("G9:L12"), .Range("G15:L18")
End With
End Sub
Public Sub SubtractArrays(firstArray As Range, secondArray As Range, targetArray As Range)
Dim thisRow As Long
Dim thisCol As Long
Dim carryValue As Long
carryValue = 0
For thisCol = 1 To firstArray.Columns.Count
For thisRow = 1 To firstArray.Rows.Count
carryValue = carryValue + firstArray.Cells(thisRow, thisCol) - secondArray.Cells(thisRow, thisCol)
If carryValue >= 0 Then
targetArray.Cells(thisRow, thisCol).Value = carryValue
carryValue = 0
Else
targetArray.Cells(thisRow, thisCol).Value = 0
End If
Next thisRow
Next thisCol
End Sub
WBD
Bookmarks