Return formula in cell

D

dhockin

XL 2003
Would like to return the address of a formula to a cell, need some
combination of Indirect and Cell (address) I think,

Example
A1 100 ( a value)
A2 = a1
A3 want to return cell addresss that formula in A2 is pointing to (ie
A1) =cell("address",a2......here's where I need the help

It would be complex if A2 had mulitple pointers, but in my case they
are just 1 cell
 
B

Bernie Deitrick

You need to use VBA. Copy the code below into a codemodule of the workbook, and use it like

=PointsTo(A2)

HTH,
Bernie
MS Excel MVP

Function PointsTo(myC As Range) As String
If myC.HasFormula Then
PointsTo = Mid(myC.Formula, 2)
Else
PointsTo = "No formula"
End If
End Function
 
G

Gary''s Student

Say A2 contains the formula:

=A1+Z10

Select A2 and run:

Sub missive()
Set r = ActiveCell
r.Offset(1, 0).Value = r.Precedents.Address
End Sub

A3 will contain:

$A$1,$Z$10
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top