View Single Post
  #15   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions
Dana DeLouis
 
Posts: n/a
Default Question On Excel Formulas

Hi. Don't know if you would be interested in this idea:
If I select your equation, and run this macro (via button for me), then I
display a message like the one below.
This only works for simple equations like yours. Doesn't work well for more
complicated equations.
I personally like to make them cell notes. Maybe this will give you some
ideas for your own:

Sub Equation_Values()
Dim v As Variant
Dim itm As Variant
Dim Fx As String
Dim s As String

Fx = ActiveCell.Formula
s = Fx & vbLf

On Error Resume Next
Set v = ActiveCell.Precedents
If Err.Number 0 Then Exit Sub

For Each itm In v
Fx = Replace(Fx, itm.Address(True, True), itm.Value)
Fx = Replace(Fx, itm.Address(True, False), itm.Value)
Fx = Replace(Fx, itm.Address(False, True), itm.Value)
Fx = Replace(Fx, itm.Address(False, False), itm.Value)
Next itm
s = s & vbLf & Fx & vbLf

For Each itm In v
s = s & vbLf & itm.Address(False, False) & ": " & itm.Value
Next itm

'// Usa a Message Box
' MsgBox s

'// Or make it a Comment
Err.Clear
ActiveCell.AddComment s
If Err.Number 0 Then ActiveCell.Comment.Text s
ActiveCell.Comment.Shape.TextFrame.AutoSize = True
End Sub


Displays:
= = = = = = =
=A1+B1+C1/D1

=5+2+3/4

A1: 5
B1: 2
C1: 3
D1: 4
= = = = = = =



--
Dana DeLouis
Win XP & Office 2003


"David Smith" wrote in message
...
Hello,

Is there a way (addin utilities or otherwise) to cause the formula in a
cell to display the values for the component references making up the
formula?

-i.e =A1 *(B2+C4)/D2

would display based on the cell reference values as:

=5*(4+6)/8

Thanks for your help,

David S