LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Challenging Macro to perform evaluate function on each cell


Hi,

I am looking to code a macro to seperate a formula by operands and
evaluate each portion individually. I am familar with programming but
not with VBA (I have a good idea of the algorithm but not enough
knowledge of VBA syntax to code). I'm hoping someone here can help

Basically what I want to do is to split a formula using the operand as
delimiter and evaluating and resubstituting the results back to the
original cell.

Example if a formula in C1 contained

=VLOOKUP(A1, RangeA, 2, FALSE) * VLOOKUP(B1, RangeB, 2, FALSE)

lets say the first portion of this VLOOKUP (on range A) returns the
number 2 and the second portion returns the number 3. I was hoping a
macro could turn this cell into

= 2 * 3

Obviously an escape character (') will be required so 2 * 3 is not
evaluated to 6.

The macro would have to work with all sorts of formulas with or without
brackets.

The alogrithm I had in mind is

LOOP worksheet for formula cells

in each formula cell cast the content of the formula as a string and
loop characters until a operand (+, -, *, /) is reached (keeping track
of the number of brackets).

If the number of "(" is equal to the number of ")" then the formula can
be evaluated in a different cell and the result substituted back to the
original formula.

If the number of "(" is not equal to the number of ")" remove the outer
")" until they are equal.

Repeat until the end of the formula is reached

Then add (') to the start of the string to prevent excel from
performing a calculation.


I know this is a big ask but does anyone have any ideas on whether this
is achievable and how I should code this?

Thanks in advanced


--
qwertyjuan
------------------------------------------------------------------------
qwertyjuan's Profile: http://www.excelforum.com/member.php...o&userid=28902
View this thread: http://www.excelforum.com/showthread...hreadid=486483

 
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
Is there a function that will evaluate a text string in a cell? Dave Excel Worksheet Functions 2 October 7th 09 04:25 AM
Reference a Macro to perform Cell formula Fred Djinn Holstings Excel Discussion (Misc queries) 1 February 2nd 07 03:50 AM
IF function - need to evaluate cell content in 2 separate files-#N PBM Excel Worksheet Functions 3 July 5th 05 08:17 AM
How do I perform a contains function for a specific cell? Vstein Excel Worksheet Functions 2 May 31st 05 10:11 AM
Getting a macro to perform a function on a certain day every week. Ian M[_2_] Excel Programming 2 July 19th 04 03:30 AM


All times are GMT +1. The time now is 01:12 AM.

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

About Us

"It's about Microsoft Excel"