Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
Dana (and other VBA experts),
In the thread "Expanding Formulas", you offered the macro below as a (great!) starting point. I made some minor modifications. The Replace() operation seems to make the appropriate substitution only for relative references of the form B1. For example, absolute references of the form $B$1 are not replaced. The root cause of the problem seems to be that p.Address(false,false) always returns a relative reference, even if the original reference is absolute. I presume that the Replace() operation is ineffective because "B1" does not match "$B$1" in the formula. Changing things to p.Address(true,true) rectifies that; but of course, then relative references are not substituted. Can the macro be changed easily to substitute all forms of references? The modified macro: Sub Demo() Dim s, p, a, v Dim cell Debug.Print "-----------" For Each cell In Selection s = cell.Formula Debug.Print s On Error Resume Next p = cell.Precedents If Err = 0 Then For Each p In cell.Precedents a = p.Address(False, False) v = p.Value s = Replace(s, a, v) Next p End If Debug.Print s Debug.Print Evaluate(s) Range("Sheet2!" & cell.Address).Formula = s Next cell End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Combine logical formulas "if", "and", "or" | Excel Discussion (Misc queries) | |||
Combining formulas, "and" & "or" to verify content of multiple cel | Excel Discussion (Misc queries) | |||
Macro to concatenate into "B1" B2 thru B"x" based on new data in "Col A" | Excel Discussion (Misc queries) | |||
Why doesn't Excel "word wrap" always expand the cell fully? | Excel Discussion (Misc queries) | |||
Make linked data "auto-expand" - (?) | Excel Discussion (Misc queries) |