Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 14
Default A function that returns the formula of a cell as a string

Hi

Does anyone know how to write a formula which will return the formula
in another cell as a string?

e.g if A3 contains the formula A1+ A2, I want to write a formula in B3
with will return the formula in A3 as string '= A1 + A2. Hence the
value in B3 will be string '= A1 + A2

Thanks in advance

Lacty
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,501
Default A function that returns the formula of a cell as a string

Hi,

With a function. Alt + F11 to open VB editor. Right click 'This Workbook'
and insert module and paste this in

Function ShowFormula(Cell As Range) As String
ShowFormula = Cell.Formula
End Function

In a worksheet cell type
=showformula(A1)

Mike

"Lacty" wrote:

Hi

Does anyone know how to write a formula which will return the formula
in another cell as a string?

e.g if A3 contains the formula A1+ A2, I want to write a formula in B3
with will return the formula in A3 as string '= A1 + A2. Hence the
value in B3 will be string '= A1 + A2

Thanks in advance

Lacty

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,441
Default A function that returns the formula of a cell as a string

Lacty,

Function MyForm(myC As Range) As String
MyForm = myC.Formula
End Function

Copy that code into a regular codemodule, then use it like

=MyForm(A3)

HTH,
Bernie
MS Excel MVP


"Lacty" wrote in message
...
Hi

Does anyone know how to write a formula which will return the formula
in another cell as a string?

e.g if A3 contains the formula A1+ A2, I want to write a formula in B3
with will return the formula in A3 as string '= A1 + A2. Hence the
value in B3 will be string '= A1 + A2

Thanks in advance

Lacty



  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 14
Default A function that returns the formula of a cell as a string

Bernie

Thanks for the response. But isn't it possible within Excel other than
using a user defined function?

Kind regards

Atem








On Mar 6, 2:12 pm, "Bernie Deitrick" <deitbe @ consumer dot org
wrote:
Lacty,

Function MyForm(myC As Range) As String
MyForm = myC.Formula
End Function

Copy that code into a regular codemodule, then use it like

=MyForm(A3)

HTH,
Bernie
MS Excel MVP

"Lacty" wrote in message

...

Hi


Does anyone know how to write a formula which will return the formula
in another cell as a string?


e.g if A3 contains the formula A1+ A2, I want to write a formula in B3
with will return the formula in A3 as string '= A1 + A2. Hence the
value in B3 will be string '= A1 + A2


Thanks in advance


Lacty


  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 510
Default A function that returns the formula of a cell as a string

Hi

Create an user defined function (UDF) for this. Open VBA Editor (Alt+F11),
add a module, and copy the code from below the
-----------

Option Explicit


Public Function ShowFormula(varCell As Range, Optional parVolatile As Date)
As String

ShowFormula = varCell.Formula

End Function
------------

Now, into B3 enter the formula
=SHOWFORMULA(A3,NOW())


Of-course this UDF example is written on fly, without any error checkings
etc., so to make it really usable, you have to improve it. But it will be a
good starting point.

--
Arvi Laanemets
( My real mail address: arvi.laanemets<attarkon.ee )



"Lacty" wrote in message
...
Hi

Does anyone know how to write a formula which will return the formula
in another cell as a string?

e.g if A3 contains the formula A1+ A2, I want to write a formula in B3
with will return the formula in A3 as string '= A1 + A2. Hence the
value in B3 will be string '= A1 + A2

Thanks in advance

Lacty





  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 14
Default A function that returns the formula of a cell as a string

Mike

Thanks for the response. But isn't it possible within Excel other than
using a user defined function?

Kind regards

Atem




On Mar 6, 2:08 pm, Mike H wrote:
Hi,

With a function. Alt + F11 to open VB editor. Right click 'This Workbook'
and insert module and paste this in

Function ShowFormula(Cell As Range) As String
ShowFormula = Cell.Formula
End Function

In a worksheet cell type
=showformula(A1)

Mike





"Lacty" wrote:
Hi


Does anyone know how to write a formula which will return the formula
in another cell as a string?


e.g if A3 contains the formula A1+ A2, I want to write a formula in B3
with will return the formula in A3 as string '= A1 + A2. Hence the
value in B3 will be string '= A1 + A2


Thanks in advance


Lacty


  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,501
Default A function that returns the formula of a cell as a string

I Don't of a method but lets wait and see if someone else does.

"Lacty" wrote:

Mike

Thanks for the response. But isn't it possible within Excel other than
using a user defined function?

Kind regards

Atem




On Mar 6, 2:08 pm, Mike H wrote:
Hi,

With a function. Alt + F11 to open VB editor. Right click 'This Workbook'
and insert module and paste this in

Function ShowFormula(Cell As Range) As String
ShowFormula = Cell.Formula
End Function

In a worksheet cell type
=showformula(A1)

Mike





"Lacty" wrote:
Hi


Does anyone know how to write a formula which will return the formula
in another cell as a string?


e.g if A3 contains the formula A1+ A2, I want to write a formula in B3
with will return the formula in A3 as string '= A1 + A2. Hence the
value in B3 will be string '= A1 + A2


Thanks in advance


Lacty



  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,441
Default A function that returns the formula of a cell as a string

Atem,

AFAIK, there is no way - possibly using some Excel 4 XLM code, but that is often a dicey
proposition.

HTH,
Bernie
MS Excel MVP


"Lacty" wrote in message
...
Bernie

Thanks for the response. But isn't it possible within Excel other than
using a user defined function?

Kind regards

Atem








On Mar 6, 2:12 pm, "Bernie Deitrick" <deitbe @ consumer dot org
wrote:
Lacty,

Function MyForm(myC As Range) As String
MyForm = myC.Formula
End Function

Copy that code into a regular codemodule, then use it like

=MyForm(A3)

HTH,
Bernie
MS Excel MVP

"Lacty" wrote in message

...

Hi


Does anyone know how to write a formula which will return the formula
in another cell as a string?


e.g if A3 contains the formula A1+ A2, I want to write a formula in B3
with will return the formula in A3 as string '= A1 + A2. Hence the
value in B3 will be string '= A1 + A2


Thanks in advance


Lacty




  #9   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 14
Default A function that returns the formula of a cell as a string

On Mar 6, 3:06 pm, "Bernie Deitrick" <deitbe @ consumer dot org
wrote:
Atem,

AFAIK, there is no way - possibly using some Excel 4 XLM code, but that is often a dicey
proposition.

HTH,
Bernie
MS Excel MVP

"Lacty" wrote in message

...

Bernie


Thanks for the response. But isn't it possible within Excel other than
using a user defined function?


Kind regards


Atem


On Mar 6, 2:12 pm, "Bernie Deitrick" <deitbe @ consumer dot org
wrote:
Lacty,


Function MyForm(myC As Range) As String
MyForm = myC.Formula
End Function


Copy that code into a regular codemodule, then use it like


=MyForm(A3)


HTH,
Bernie
MS Excel MVP


"Lacty" wrote in message


...


Hi


Does anyone know how to write a formula which will return the formula
in another cell as a string?


e.g if A3 contains the formula A1+ A2, I want to write a formula in B3
with will return the formula in A3 as string '= A1 + A2. Hence the
value in B3 will be string '= A1 + A2


Thanks in advance


Lacty




Bernie

I have gone with the UDF. It very simple and easy to use. If I take
this one step further, I have some cells with range names so using the
udf MyForm() returns = RangeName. Is it possible to write a code or
function that would return the actual cell address as oppose to the
range name?

Thanks very much
  #10   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,441
Default A function that returns the formula of a cell as a string

Atem,

Give this version a try - it will replace single name references in cases like

=myName

but not in cases like

=myName * 4


HTH,
Bernie
MS Excel MVP

Function MyForm(myC As Range) As String
Dim myAdd As String
MyForm = myC.Formula
On Error GoTo NotName
myAdd = Range(Mid(MyForm, 2, Len(MyForm))).Address(False, False)
MyForm = "=" & myAdd
NotName:
End Function




"Lacty" wrote in message
...
On Mar 6, 3:06 pm, "Bernie Deitrick" <deitbe @ consumer dot org
wrote:
Atem,

AFAIK, there is no way - possibly using some Excel 4 XLM code, but that is often a dicey
proposition.

HTH,
Bernie
MS Excel MVP

"Lacty" wrote in message

...

Bernie


Thanks for the response. But isn't it possible within Excel other than
using a user defined function?


Kind regards


Atem


On Mar 6, 2:12 pm, "Bernie Deitrick" <deitbe @ consumer dot org
wrote:
Lacty,


Function MyForm(myC As Range) As String
MyForm = myC.Formula
End Function


Copy that code into a regular codemodule, then use it like


=MyForm(A3)


HTH,
Bernie
MS Excel MVP


"Lacty" wrote in message


...


Hi


Does anyone know how to write a formula which will return the formula
in another cell as a string?


e.g if A3 contains the formula A1+ A2, I want to write a formula in B3
with will return the formula in A3 as string '= A1 + A2. Hence the
value in B3 will be string '= A1 + A2


Thanks in advance


Lacty




Bernie

I have gone with the UDF. It very simple and easy to use. If I take
this one step further, I have some cells with range names so using the
udf MyForm() returns = RangeName. Is it possible to write a code or
function that would return the actual cell address as oppose to the
range name?

Thanks very much



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
use concatenate function to put carrage returns in a text string dabblingandconfused Excel Worksheet Functions 4 August 15th 06 04:58 PM
IF function which returns the text from a cell Wilhelm Excel Worksheet Functions 1 July 6th 06 09:14 AM
IF Function returns result of formula AKlein Excel Discussion (Misc queries) 2 March 2nd 06 04:28 PM
Function that Returns address of that cell? RayWolfDog Excel Worksheet Functions 2 February 15th 06 04:54 PM
If function that returns value in a cell. rayteach Excel Worksheet Functions 4 June 6th 05 03:26 AM


All times are GMT +1. The time now is 01:54 PM.

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"