Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default extracting parameters from formula

Hi all

Is there an easy way to extract the parameter values used
in a function, e.g.
if a cell contains a formula "=sum(a1,a2,a3)", I'd like to
get an array with the values (a,b,c) ( =values of a1, a2,
a3) being used in the function. The function wizard in
excel takes the function apart in this way, but it looks
quite complex to try and do something similar. I am
tempted to take the formula apart as a string, going
for "(" and ",", but it doesn't look easy. Maybe there's a
ready made procedure for this?

Thanks for your input
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 599
Default extracting parameters from formula

Claude

The Precedents collection might help you here. You can loop through the
Precedents of cell and it will return a collection of Range objects from
which you can get the values. It doesn't return all the arguments, unless
they happen to be cell references, so it would work for your example, but
not

=Sum(A1,10,B2)

That would only return A1 and B2, not the scalar value 10. Here's an
example of how to use Precedents.

http://www.dicks-blog.com/excel/2004...recedents.html

If you need all arguments, not just cell references, then I think parsing
the Formula property is the only way to go. But it won't be easy.

--
Dick Kusleika
MVP - Excel
Excel Blog - Daily Dose of Excel
www.dicks-blog.com

"Claude" wrote in message
...
Hi all

Is there an easy way to extract the parameter values used
in a function, e.g.
if a cell contains a formula "=sum(a1,a2,a3)", I'd like to
get an array with the values (a,b,c) ( =values of a1, a2,
a3) being used in the function. The function wizard in
excel takes the function apart in this way, but it looks
quite complex to try and do something similar. I am
tempted to take the formula apart as a string, going
for "(" and ",", but it doesn't look easy. Maybe there's a
ready made procedure for this?

Thanks for your input



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
Logic If formula - multi-parameters can not get to work?? Tech Express Excel Worksheet Functions 3 April 10th 09 03:17 PM
SUBSTITUTE formula -- variable spacing between parameters?? The Moose Excel Worksheet Functions 6 December 2nd 06 07:00 PM
Parameters for an excel formula guatdoc Excel Discussion (Misc queries) 1 September 14th 06 04:50 AM
formula to check balances within parameters Todd Excel Worksheet Functions 2 March 9th 06 12:00 AM
MID formula not extracting what I want. wayliff Excel Discussion (Misc queries) 5 January 13th 06 03:57 PM


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

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"