Be careful, you have trailing space in B98 and the code will look for that row.
Sub test()
Dim x, myAreas As Areas, myArea As Range, txt As String, myCols As Long
With Sheets("Payback Calculator")
x = Filter(.[transpose(if((b1:b1000="Start Date")+(b1:b1000="Costs of Development and Operation")+(b1:b1000="Revenue Contribution "),row(1:1000)))], False, 0)
If UBound(x) < 2 Then
MsgBox "Missing something": Exit Sub
End If
Set myAreas = Intersect(.Rows(x(0) & ":" & x(1)), .Columns("f")).SpecialCells(-4123, 1).Areas
For Each myArea In myAreas
If (myArea.Count = 1) * (Not IsDate(myArea(1).Value)) Then
txt = txt & "," & myArea.Address(0, 0)
myCols = Application.Max(myCols, myArea.CurrentRegion.Columns.Count)
End If
Next
.Cells(x(2), "f").Resize(, myCols) = "=sum(" & Mid(txt, 2) & ")"
End With
End Sub
Bookmarks