Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default How to get variable from a formula

Hi,

I would like to ask, whether it is possible to get information of a variable
in a formula, I mean:

Cell B1 contains formula:

=SPEC("Green","Apple",98),

is that possible somehow to reach the middle parameter of the function, that
is "Apple"?

Is there any VBA function like:

needed = Cells(1,2).Formula.Parameter(2)

Thanks in advance
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default How to get variable from a formula

Sub marine()
dq = Chr(34)
MsgBox (Split(Range("B1").Formula, dq)(1))
End Sub

--
Gary''s Student - gsnu200794


"pontitt" wrote:

Hi,

I would like to ask, whether it is possible to get information of a variable
in a formula, I mean:

Cell B1 contains formula:

=SPEC("Green","Apple",98),

is that possible somehow to reach the middle parameter of the function, that
is "Apple"?

Is there any VBA function like:

needed = Cells(1,2).Formula.Parameter(2)

Thanks in advance

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default How to get variable from a formula

You could user .formula to return the formula string.

Then parse that formula to look between the initial open paren and closing paren
to get the parms that you're passing.

Then you could use split (in xl2k and higher) to dump that in an array
(separated by commas).



pontitt wrote:

Hi,

I would like to ask, whether it is possible to get information of a variable
in a formula, I mean:

Cell B1 contains formula:

=SPEC("Green","Apple",98),

is that possible somehow to reach the middle parameter of the function, that
is "Apple"?

Is there any VBA function like:

needed = Cells(1,2).Formula.Parameter(2)

Thanks in advance


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default How to get variable from a formula

Tricky, good as base approach, thanks

"Gary''s Student" wrote:

Sub marine()
dq = Chr(34)
MsgBox (Split(Range("B1").Formula, dq)(1))
End Sub

--
Gary''s Student - gsnu200794


"pontitt" wrote:

Hi,

I would like to ask, whether it is possible to get information of a variable
in a formula, I mean:

Cell B1 contains formula:

=SPEC("Green","Apple",98),

is that possible somehow to reach the middle parameter of the function, that
is "Apple"?

Is there any VBA function like:

needed = Cells(1,2).Formula.Parameter(2)

Thanks in advance

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to get variable from a formula

I think you meant to type 44 (for a comma), not 34 (for a quote mark), in
your first statement (otherwise you get Green instead of "Apple"); although
you really do not need to use a variable to handle this...

MsgBox Split(Range("C1").Formula, ",")(1)

Rick


"Gary''s Student" wrote in message
...
Sub marine()
dq = Chr(34)
MsgBox (Split(Range("B1").Formula, dq)(1))
End Sub

--
Gary''s Student - gsnu200794


"pontitt" wrote:

Hi,

I would like to ask, whether it is possible to get information of a
variable
in a formula, I mean:

Cell B1 contains formula:

=SPEC("Green","Apple",98),

is that possible somehow to reach the middle parameter of the function,
that
is "Apple"?

Is there any VBA function like:

needed = Cells(1,2).Formula.Parameter(2)

Thanks in advance


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 containing a formula-dependent variable - how? CompeterN New Users to Excel 1 November 8th 06 02:02 PM
Using a second variable within a formula... Ed Anton Excel Discussion (Misc queries) 2 February 18th 05 11:51 AM
use a variable in a formula Marcotte A Excel Programming 2 August 26th 04 01:24 AM
Variable in a Formula Amy Ja Excel Programming 3 April 21st 04 01:22 AM
Formula Variable Ronbo Excel Programming 3 March 4th 04 09:33 PM


All times are GMT +1. The time now is 09:10 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"