View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Auric__ Auric__ is offline
external usenet poster
 
Posts: 538
Default Display formulae as values of each cell reference

plotzmoney wrote:

Hello all, I was wondering if someone could please help me with a macro.
Any and all help is appreciated:

Essentially, it would be a macro where you take a cell (which has
various formulas and cell references in it) and convert those formulas
and references into their values within the formula bar into a separate
cell next to it.

For example:

Where Cell A1 = Cells (F2+F3+F4)/F5
F2 = 50
F3= 200
F4= 250
F5=100

Steps for Macro

1. I would highlight cell A1 (or if multiple cells, I would highlight
all of them)
2. I would run the macro

Macro Output

1. The macro would paste a formula into the corresponding cells directly
to the right of it. (In this case, it would be cell B1)
2. In cell B1, the cell would show a value of "5", and would show the
following formula: =(50+200+250)/100


As it happens, I solved a similar problem for myself some time ago. Try this:

Sub SelectionFormula2Value()
Dim cell As Range
For Each cell In Selection.Cells
cell.Offset(0, 1).Formula = "'" & cell.Formula
Next
End Sub

--
Since all the ideas involve you, I'm not suprised.