Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
dan dan is offline
external usenet poster
 
Posts: 866
Default Evaluate formula

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Evaluate formula

It is possible but very complicated. It is a language parsing problem. The
worksheet formulas have a syntax that must be defined. I would search the
web for a general purpose PARSER.

The solution usualy uses a recursive algorithm to get the individual pieces.
The formulas have parenthesis and you need performa the operations following
the parenthesis.

There are better programming languages to do these tasks than BASIC. SNOBOL
programming language is one of the programming languages is designed to
handle these type problems.

"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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Formula will not evaluate in VBA [email protected] Excel Programming 3 June 15th 07 11:07 PM
Might be a bug in Evaluate Formula? cyx Excel Discussion (Misc queries) 2 May 2nd 07 10:52 PM
What is evaluate formula? Rasoul Khoshravan Excel Worksheet Functions 11 October 27th 06 01:52 PM
Formula Will Not Evaluate Cecil Excel Worksheet Functions 3 April 25th 06 07:38 PM
Evaluate formula using VBA Ali Baba Excel Discussion (Misc queries) 0 August 17th 05 12:31 AM


All times are GMT +1. The time now is 11:21 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"