Home |
Search |
Today's Posts |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Option Explicit
Sub test() ResolveFormula Range("D6") End Sub Sub ResolveFormula1(rngCell As Range) Dim sCell As String Dim rngPrec As Range Dim index As Long sCell = rngCell.Formula index = 64 For Each rngPrec In rngCell.DirectPrecedents index = index + 1 sCell = Replace(sCell, rngPrec.Address(False, False), Chr(index)) Next rngcell.offaset(,1).Value= "'" & sCell End Sub "Kevin Beckham" wrote: With a leading space so it is not a true formula " =A * B" With error-trapping, it can be called from a sub-routine, but not from a worksheet "Kevin Beckham" wrote: I didn't express myself clearly I would like it to return the string "=A * B" At present, it returns "=B1 * B2" "Patrick Molloy" wrote: you can't put = A * B into a cell, its "illegal" "Kevin Beckham" wrote: I can't get the following function to return the direct dependents Function ResolveFormula(ByRef rngCell As Range, iColLabels As Integer) As String Dim sCell As String Dim rngPrec As Range sCell = rngCell.Formula For Each rngPrec In rngCell.DirectPrecedents With rngPrec sCell = Replace(sCell, rngPrec.Address(False, False, xlA1), _ .Offset(0, iColLabels - .Column + 1).Value) End With Next rngPrec ResolveFormula = sCell End Function For the worksheet A 1 B 2 =B1 * B2 =ResolveFormula(B3, 1) to give =A * B TIA Kevin Beckham |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
DirectDependents not working properly. | Excel Programming | |||
What's the difference between .Dependents and .DirectDependents? | Excel Programming | |||
Finding when there are no directdependents | Excel Programming | |||
Problem when multipple users access shared xl-file at the same time, macrocode for solve this problem? | Excel Programming |