Advertisement
Guest User

Untitled

a guest
Jul 25th, 2014
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. = CONCATENATE("= (";SUBSTITUTE(FORMULATEXT(A1);"=";"");") + (";SUBSTITUTE(FORMULATEXT(B1);"=";"");")
  2.  
  3. =CombineFormulas(A1:B1,"+")
  4.  
  5. Option Explicit
  6. Public Function CombineFormulas(RangeToCombine As Range, Operator As String)
  7. 'Input: Range of cells and an operator to use when combining their formulas
  8. 'Output: String of the combined formulas
  9. Dim cell As Range
  10. Dim s As String
  11. s = "="
  12. For Each cell In RangeToCombine.Cells
  13. If Len(s) > 1 Then s = s & Operator
  14. s = s & "(" & Mid(cell.Formula, 2, Len(cell.Formula)) & ")"
  15. Next
  16. Application.Volatile
  17. CombineFormulas = Evaluate(s)
  18. End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement