View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Gary''s Student Gary''s Student is offline
external usenet poster
 
Posts: 11,058
Default Evaluate formula

You need to input the formula as Text and parse it. Then EVALUATE the parsed
items.

Say in Cell A1 we have:

=(1+2) + (3+4)

then:

Sub pieces()
Dim s As String
s = Range("A1").Formula
s2 = Replace(s, ")", "(")
s3 = Split(s2, "(")
MsgBox (Evaluate(s3(1)))
MsgBox (Evaluate(s3(3)))
End Sub


This is NOT a solution, only posted to give you the general idea.
--
Gary''s Student - gsnu200825


"Dan" wrote:

Hi,
Is it possible via vba to dissect a spreadsheet formula and evualte every
part of it?
I do not need an addin that do it (I thik it exists on the net) - I need to
understand how to do it - so I need to see the code behind the solution.
Many Thanks,
RG