Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 12
Default Function to return formula

What is the best way to return a cell's formula (using a function)?

I'm thinking along the lines of this (fictional) function:

=CELL("formula",A1)

TIA,

Ed

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,696
Default Function to return formula

Are you looking for your function to return the text of the formula, or just
have the same formula?

If you just want both cells to have the same formula, just put $ in front of
both parts of your cell reference.
so, if the formula is =A2, change the formula to =$A$2. then, no matter
where you put it, it will return the same value.

"Edward" wrote:

What is the best way to return a cell's formula (using a function)?

I'm thinking along the lines of this (fictional) function:

=CELL("formula",A1)

TIA,

Ed


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 7,247
Default Function to return formula

You can''t do it with a formula. You need to use a VBA function. E.g,

Public Function GetFormula(Rng As Range, _
Optional GetValueIfNoFormula As Boolean = True) As Variant

If Rng.Cells.Count 1 Then
GetFormula = CVErr(xlErrRef)
Exit Function
End If
If Rng.HasFormula = True Then
GetFormula = Rng.Formula
Else
If GetValueIfNoFormula = True Then
GetFormula = Rng.Value
Else
GetFormula = vbNullString
End If
End If

End Function

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email on the web site)


"Edward" wrote in message
ups.com...
What is the best way to return a cell's formula (using a function)?

I'm thinking along the lines of this (fictional) function:

=CELL("formula",A1)

TIA,

Ed



  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,572
Default Function to return formula

Caveat -

This should be used in XL02 or later.
Earlier versions *will* crash when copying this type of formula to other
WBs.
Can be used in earlier versions, as long as copying is restricted to within
the existing WB.

Start my creating a 'named' formula that will return the actual formula from
A1;


Click in B1, then,
<Insert <Name <Define,
In the "Names In Workbook" box, enter a short name, say
form
for formula.
In the "Refers To" box, replace whatever's there with this formula:
=GET.CELL(6,A1)
Then <OK


What you have now is a 'relative' *named formula* that when entered in *any*
cell, will return the contents of the cell (text, data, formulas) from the
*previous* column.

So, with A1 containing:

=A2+A3+A4

In B1 enter:

=form

To get the contents of A1.


--

HTH,

RD
================================================== ===
Please keep all correspondence within the Group, so all may benefit!
================================================== ===



"Edward" wrote in message
ups.com...
What is the best way to return a cell's formula (using a function)?

I'm thinking along the lines of this (fictional) function:

=CELL("formula",A1)

TIA,

Ed


  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 12
Default Function to return formula

I tried your suggestion, and it works. Thanks.

Where can I get more information about similar functions?

This is new to me.

Thanks again,

Ed

RagDyeR wrote:
Caveat -

This should be used in XL02 or later.
Earlier versions *will* crash when copying this type of formula to other
WBs.
Can be used in earlier versions, as long as copying is restricted to within
the existing WB.

Start my creating a 'named' formula that will return the actual formula from
A1;


Click in B1, then,
<Insert <Name <Define,
In the "Names In Workbook" box, enter a short name, say
form
for formula.
In the "Refers To" box, replace whatever's there with this formula:
=GET.CELL(6,A1)
Then <OK


What you have now is a 'relative' *named formula* that when entered in *any*
cell, will return the contents of the cell (text, data, formulas) from the
*previous* column.

So, with A1 containing:

=A2+A3+A4

In B1 enter:

=form

To get the contents of A1.


--

HTH,

RD
================================================== ===
Please keep all correspondence within the Group, so all may benefit!
================================================== ===



"Edward" wrote in message
ups.com...
What is the best way to return a cell's formula (using a function)?

I'm thinking along the lines of this (fictional) function:

=CELL("formula",A1)

TIA,

Ed




  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,572
Default Function to return formula

These are called XL 4.0 macros.

Try this:

http://tinyurl.com/seb4r

--
Regards,

RD

---------------------------------------------------------------------------
Please keep all correspondence within the NewsGroup, so all may benefit !
---------------------------------------------------------------------------
"Edward" wrote in message
ups.com...
I tried your suggestion, and it works. Thanks.

Where can I get more information about similar functions?

This is new to me.

Thanks again,

Ed

RagDyeR wrote:
Caveat -

This should be used in XL02 or later.
Earlier versions *will* crash when copying this type of formula to other
WBs.
Can be used in earlier versions, as long as copying is restricted to
within
the existing WB.

Start my creating a 'named' formula that will return the actual formula
from
A1;


Click in B1, then,
<Insert <Name <Define,
In the "Names In Workbook" box, enter a short name, say
form
for formula.
In the "Refers To" box, replace whatever's there with this formula:
=GET.CELL(6,A1)
Then <OK


What you have now is a 'relative' *named formula* that when entered in
*any*
cell, will return the contents of the cell (text, data, formulas) from
the
*previous* column.

So, with A1 containing:

=A2+A3+A4

In B1 enter:

=form

To get the contents of A1.


--

HTH,

RD
================================================== ===
Please keep all correspondence within the Group, so all may benefit!
================================================== ===



"Edward" wrote in message
ups.com...
What is the best way to return a cell's formula (using a function)?

I'm thinking along the lines of this (fictional) function:

=CELL("formula",A1)

TIA,

Ed



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
Is this possible with excel ? ChrisB Excel Discussion (Misc queries) 14 December 30th 06 12:31 AM
Use of Offset function in array formula scabHead Excel Worksheet Functions 4 December 23rd 06 01:16 AM
Match then lookup Tenacity Excel Worksheet Functions 9 December 3rd 05 05:30 AM
function CELL() to return the formula in the referenced cell Streep Excel Worksheet Functions 3 August 20th 05 10:24 PM
Excel option to store trendline's coefficients in cells for use Miguel Saldana Charts and Charting in Excel 9 June 20th 05 08:45 PM


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