#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Get Formula

I use the following VBA

Function GetFormula(Cell as Range) as String
GetFormula = Cell.Formula
End Function

When inserting =Getformula(A5) it actually returns the formula in writing like
"=A3*B3"

I would like to incoorparate the following

Make the code working when using vlookup to select the cell
=Getformula(Vlookup,A20,.......))

Retrun the actual working formula not the text, as I will have formula's in
a lookup table using the ROW() refference the make thins working.


Thanks,

W:-)
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 269
Default Get Formula

I see a couple of issues here

You have defined GetFormula as a string, thus a text string is the result.
A text string will not be treated like a formula.

The Vlookup function will return the result contained in a given cell, it
will not return the cell address.

I am not sure that you really can get a User Defined Function to insert a
formula in a cell. A function returns a result, the result may look like a
formula, but I don't know if you can get Excel to treat it as a formula.

VBA can add a formula to a cell. Activecell.formula="=A3*B3" would add a
functioning formula to the cell.

I think you may need to change to a button called or Event called macro to
get want you want

Private Sub Worksheet_Change(ByVal Target As Range)
'Do Stuff
End Sub


Will run everytime the sheet is changed. You could likely structure some
code to find the correct formula and put in into the correct cell or cells.

--
If this helps, please remember to click yes.


"willemeulen" wrote:

I use the following VBA

Function GetFormula(Cell as Range) as String
GetFormula = Cell.Formula
End Function

When inserting =Getformula(A5) it actually returns the formula in writing like
"=A3*B3"

I would like to incoorparate the following

Make the code working when using vlookup to select the cell
=Getformula(Vlookup,A20,.......))

Retrun the actual working formula not the text, as I will have formula's in
a lookup table using the ROW() refference the make thins working.


Thanks,

W:-)

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
Regression Leverage Formula (Jerry W. Lewis or Mike Middleton)already have DFITS formula PJ[_3_] Excel Worksheet Functions 2 June 2nd 10 03:45 PM
Excel 2002 Formula: Urgent Conditional Formula Required Right Away - if possible blue[_2_] Excel Discussion (Misc queries) 2 July 11th 07 06:08 PM
Build excel formula using field values as text in the formula val kilbane Excel Worksheet Functions 2 April 18th 07 01:52 PM
Formula expected end of statement error, typing formula into cell as part of VBA macro [email protected] Excel Programming 1 July 20th 06 07:58 PM
Commenting custom formula fields/formula on formula editor Muxer Excel Programming 2 July 24th 03 01:02 AM


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