Possibly this will work for you.
Given a cell that contains a formula, ConstantReplace will return the formula in that cell with the cell references replaced by their values.
Those replaced values are surrounded by square brackets to distinguish from constants in the formula.
The example in the OP would return [5000]/1000
Note that the formula can only refer to open workbooks. It doesn't work for closed workbooks.
Note also that, multi-cell references, like SUM(A1:B2) are not changed. (Would one want to return only the two values in A1 and B2 or all four values or ....)
Also, the leading = has been removed from the formula so that the string can be placed in a cell without being interpreted as a formula
Finally, ConstantReplace cannot be used as a UDF.
Note the testing sub at the bottom of the code.
(I join with Aussiebear in wondering "why?")
Function ConstantReplace(CellWithFormula As Range) As String
Dim i As Long, j As Long, pointer As Long
Dim strFormula As String, strReplacement As Variant
Dim colPrecedents As New Collection
Dim onePrecedent As Range, oneAddress As String
Dim allPrecedents() As String
ReDim allPrecedents(1 To 1)
With CellWithFormula.Cells(1, 1)
strFormula = .Formula
strFormula = Application.ConvertFormula(strFormula, xlA1, xlA1, xlAbsolute)
.Parent.ClearArrows
.ShowPrecedents
Rem build array of all precedent references
i = 1
Do
On Error Resume Next
Set onePrecedent = .NavigateArrow(True, 1, i)
colPrecedents.Add Item:=onePrecedent, Key:=onePrecedent.Address
Loop Until Err
i = 1
Do
Set onePrecedent = .NavigateArrow(True, i, 1)
On Error Resume Next
colPrecedents.Add Item:=onePrecedent, Key:=onePrecedent.Address
Err.Clear
i = i + 1
Loop Until onePrecedent.Address(, , , True) = .Address(, , , True)
For Each onePrecedent In colPrecedents
If onePrecedent.Address(, , , True) <> .Address(, , , True) Then
' add "[Workbook1.xlsm]Sheet1!$A$1" to array
oneAddress = onePrecedent.Address(, , , True)
GoSub AddOneAddressToArray
If onePrecedent.Parent.Parent.Name = .Parent.Parent.Name Then
' if oneprecident is in my workbook add "Sheet1!$A$1" to array
oneAddress = Replace(onePrecedent.Address(, , , True), "[" & onePrecedent.Parent.Parent.Name & "]", vbNullString)
GoSub AddOneAddressToArray
If onePrecedent.Parent.Name = .Parent.Name Then
'if onePresident is on same sheet then add "$A$1" to array
oneAddress = onePrecedent.Address
GoSub AddOneAddressToArray
End If
End If
End If
Next onePrecedent
End With
If 0 < pointer Then
ReDim Preserve allPrecedents(1 To pointer)
Rem sort allprecedents on length of address
For i = 1 To pointer - 1
For j = i + 1 To pointer
If Len(allPrecedents(i)) < Len(allPrecedents(j)) Then
oneAddress = allPrecedents(i)
allPrecedents(i) = allPrecedents(j)
allPrecedents(j) = oneAddress
End If
Next j
Next i
Rem replace references with values
For i = 1 To pointer
strReplacement = Chr(5)
If Range(allPrecedents(i)).Count = 1 Then
strReplacement = Evaluate(allPrecedents(i))
If strReplacement = vbNullString Then
strReplacement = """"""
Else
Select Case TypeName(strReplacement)
Case "String"
strReplacement = Chr(34) & strReplacement & Chr(34)
Case "Boolean"
strReplacement = UCase(CStr(strReplacement))
Case "Double"
strReplacement = CStr(strReplacement)
End Select
End If
strReplacement = "[" & strReplacement & "]"
End If
If strReplacement <> Chr(5) Then
strFormula = Replace(strFormula, allPrecedents(i), strReplacement)
End If
Next i
If strFormula Like "=*" Then strFormula = Mid(strFormula, 2)
ConstantReplace = strFormula
Else
ConstantReplace = CellWithFormula.Cells(1, 1).Text
End If
Set colPrecedents = Nothing
CellWithFormula.Parent.ClearArrows
Exit Function
AddOneAddressToArray:
pointer = pointer + 1
If UBound(allPrecedents) < pointer Then ReDim Preserve allPrecedents(1 To 2 * pointer)
allPrecedents(pointer) = oneAddress
Return
End Function
Sub test()
Dim oneCell As Range
For Each oneCell In Sheet1.Cells.SpecialCells(xlCellTypeFormulas)
oneCell.Offset(10, 0) = ConstantReplace(oneCell)
Next oneCell
End Sub