Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Nelson
 
Posts: n/a
Default Referencing a formula (as text)

Hi, can anyone help with the following?

I want to pick up a formula (written as text) from one cell so it can be
used in another function? This will then be applied to a range of cells by
filling-down.

For example if I write a function as VLOOKUP(X,Table,3,false) without the =
sign and therefore store it in a cell as text, I want to be able to
reference that cell and apply the function.

Is this possible?

Nelson


  #2   Report Post  
Bob Umlas, Excel MVP
 
Posts: n/a
Default

You'd need a macro to do that. If that formula were in D3, for example, this
line of VBA would do it:
Answer = evaluate("=" & [d3])

Bob Umlas

"Nelson" wrote:

Hi, can anyone help with the following?

I want to pick up a formula (written as text) from one cell so it can be
used in another function? This will then be applied to a range of cells by
filling-down.

For example if I write a function as VLOOKUP(X,Table,3,false) without the =
sign and therefore store it in a cell as text, I want to be able to
reference that cell and apply the function.

Is this possible?

Nelson



  #3   Report Post  
Dave Peterson
 
Posts: n/a
Default

Just to add to Bob's response....

You'd need a User Defined Function.

This one worked ok for me:

Option Explicit
Function Eval(str As String) As Variant
With Application
.Volatile
Eval = .Evaluate(str)
End With
End Function

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Short course:

Open your workbook.
Hit alt-f11 to get to the VBE (where macros/UDF's live)
hit ctrl-R to view the project explorer
Find your workbook.
should look like: VBAProject (yourfilename.xls)

right click on the project name
Insert, then Module
You should see the code window pop up on the right hand side

Paste the code in there.

Now go back to excel.
Into a test cell and type:
=eval(a1)

Where A1 contains your formula/string.

Nelson wrote:

Hi, can anyone help with the following?

I want to pick up a formula (written as text) from one cell so it can be
used in another function? This will then be applied to a range of cells by
filling-down.

For example if I write a function as VLOOKUP(X,Table,3,false) without the =
sign and therefore store it in a cell as text, I want to be able to
reference that cell and apply the function.

Is this possible?

Nelson


--

Dave Peterson
  #4   Report Post  
Nelson
 
Posts: n/a
Default

Thanks everyone,

Will look at David McRitches site.

Nelson



"Dave Peterson" wrote in message
...
Just to add to Bob's response....

You'd need a User Defined Function.

This one worked ok for me:

Option Explicit
Function Eval(str As String) As Variant
With Application
.Volatile
Eval = .Evaluate(str)
End With
End Function

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Short course:

Open your workbook.
Hit alt-f11 to get to the VBE (where macros/UDF's live)
hit ctrl-R to view the project explorer
Find your workbook.
should look like: VBAProject (yourfilename.xls)

right click on the project name
Insert, then Module
You should see the code window pop up on the right hand side

Paste the code in there.

Now go back to excel.
Into a test cell and type:
=eval(a1)

Where A1 contains your formula/string.

Nelson wrote:

Hi, can anyone help with the following?

I want to pick up a formula (written as text) from one cell so it can be
used in another function? This will then be applied to a range of cells
by
filling-down.

For example if I write a function as VLOOKUP(X,Table,3,false) without the
=
sign and therefore store it in a cell as text, I want to be able to
reference that cell and apply the function.

Is this possible?

Nelson


--

Dave Peterson



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
Coverting Formula to Text Catch 22 Excel Discussion (Misc queries) 3 April 1st 05 01:13 AM
merging text without using a formula April Excel Discussion (Misc queries) 4 February 16th 05 01:07 AM
Referencing Sheets in a Formula Christopher Anderson Excel Discussion (Misc queries) 1 January 31st 05 04:10 PM
formula referencing another workbook Steve D Excel Worksheet Functions 2 January 7th 05 09:43 PM
Concatenation formula loses text wrap formatting DFM Excel Discussion (Misc queries) 5 December 27th 04 01:45 PM


All times are GMT +1. The time now is 05:18 PM.

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"