You can't write a formula, that will be operate on textboxes. The best way is write UDF, for example:
Function MyFormula (TBox83 MSForms.TextBox, TBox97 as MSForms.TextBox, TBox65 as MSForms.TextBox, TBox28 as MSForms.TextBox ......) as Double
If TBox83.Value = -65 Then
MyFormula = 0
Else
MyFormula = TBox65.Value + TBox35.Value + TBox36.Value ......
end If
End Function
The second way is write UDF, that will be operate on spreadsheet, where you can use spreadsheet's functions:
Function MyFromula (rng83 as Range, rng65 as Range, rng35_37 as Range .......) as Double
If rng83.Value = -65 Then
MyFormula = 0
Else
MyFromula = rng65.Value + WorksheetFunction.Sum(Range(rng35_37.Address)) + rng83.Value - WorksheetFunction.Sum(Range(rng39_48.Address)).......)
End If
End Function
Of course there is much more solutions.
Bookmarks