Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 13
Default Extract portion of formula resident in a cell

I want to extract a cell reference from a formula in a cell

I tried the right function referenceing the cell but it returns the right
portion of the function result

how do I specify it to extract the physical formula text in the cell and not
the formula value in the cell?

example... a cell b5 contains the formula "='Execute Dealer Plan'!$P647"
which has a value of "select status"
if cell b6 contains formula "=right(b5,4) I'm wanting "P647" returned and
not "atus"



--
Jim
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,268
Default Extract portion of formula resident in a cell

You can't without using VBA or excel4 macros, why would you think that? You
can't have the cake and eat it, of course if you format the cell as text
before you type in the source formula you can do this, I doubt you want that
though

http://www.mvps.org/dmcritchie/excel/formula.htm


shows a UDF that will return the formula as a text string, then you can wrap
it in the RIGHT function


=RIGHT(getformula(B5),4)



--
Regards,

Peo Sjoblom





"JASelep" wrote in message
...
I want to extract a cell reference from a formula in a cell

I tried the right function referenceing the cell but it returns the right
portion of the function result

how do I specify it to extract the physical formula text in the cell and
not
the formula value in the cell?

example... a cell b5 contains the formula "='Execute Dealer Plan'!$P647"
which has a value of "select status"
if cell b6 contains formula "=right(b5,4) I'm wanting "P647" returned and
not "atus"



--
Jim



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,651
Default Extract portion of formula resident in a cell

On Wed, 29 Aug 2007 07:46:05 -0700, JASelep wrote:

I want to extract a cell reference from a formula in a cell

I tried the right function referenceing the cell but it returns the right
portion of the function result

how do I specify it to extract the physical formula text in the cell and not
the formula value in the cell?

example... a cell b5 contains the formula "='Execute Dealer Plan'!$P647"
which has a value of "select status"
if cell b6 contains formula "=right(b5,4) I'm wanting "P647" returned and
not "atus"



You cannot do this with a built-in excel function. The simplest method would
be to use a UDF to return the cell formula as text. (You can also do this
using Excel 4.0 XLM macro techniques, but I think that is more convoluted).

To enter the UDF, <alt-F11 opens the VBEditor. Ensure your project is
highlighted in the project explorer window, then Insert/Module and paste the
code below into the window that opens.

To use this, =getformula(cell_ref) will return the formula in the cell as text.
You can then use MID, LEFT and RIGHT or other text processing methods to return
the desired portion of the formula.

================================
Function GetFormula(cell_ref As Range) As String
GetFormula = cell_ref.Formula
End Function
===============================
--ron
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
excel formula referring to a decimal portion of another cell teenerx5 Excel Worksheet Functions 1 February 24th 07 05:58 PM
A formula for moving a portion of a cell??? McKenna Excel Discussion (Misc queries) 4 February 20th 07 10:23 PM
I need to search for then extract a specific portion of cell data... Ken Excel Worksheet Functions 15 September 6th 06 11:53 AM
How I can to extract a formula from other Cell Function? Tinjano Excel Discussion (Misc queries) 1 May 15th 05 08:24 PM
Extract Portion of field into other fields Jay Excel Worksheet Functions 7 December 18th 04 02:01 AM


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