ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Showing Formula (https://www.excelbanter.com/excel-programming/399004-showing-formula.html)

JV

Showing Formula
 
Hello

I have a cell calculate based on info from other cells. How do I make the
cell show the formula when selected instead of the hardcoded result?

Thanks in advance.

eliano

Showing Formula
 
Hi JV.
Try:

Public Function MyValue(aCell As Range) As Variant
by Norman Jones in m.p.i.o.e
Dim myVal As Variant
myVal = Replace(aCell.Formula, Application. _
International(xlDecimalSeparator), ".")
myVal = Evaluate(myVal)
If IsError(myVal) Then
MyValue = CVErr(xlErrNA)
Else
MyValue = myVal
End If
End Function

in A1: D1+E1*F1-10
in B1: =MyValue(A1)

Regards
Eliano

"JV" wrote:

Hello

I have a cell calculate based on info from other cells. How do I make the
cell show the formula when selected instead of the hardcoded result?

Thanks in advance.



All times are GMT +1. The time now is 09:58 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com