JenniferMurphy
Well-known Member
- Joined
- Jul 23, 2011
- Messages
- 2,546
- Office Version
- 365
- Platform
- Windows
I wrote a GetFormula UDF many years ago before Excel had the FormulaText function. Sometime in the past several months, it started getting a #VALUE error before it is even called. If I change the name, it works. Here's the code. Is "getformula" now a reserved word?
VBA Code:
Function GetFormula(pCell As Range, Optional pAddrSw As Boolean = True) As String
GetFormula = pCell(1).FormulaArray 'Get the formula in the cell
If pCell(1).HasArray Then 'If it's an array formula,
GetFormula = "{" & GetFormula & "}" '.add the {}s
End If
If pAddrSw Then 'If switch is on, add the cell address and leading quote, if any
GetFormula = pCell(1).Address(0, 0) & ": " & pCell(1).PrefixCharacter & GetFormula
End If
End Function