Forum Discussion
MelvynM
Feb 06, 2024Copper Contributor
Excel - Evaluate two times a formula
Hello, In order to do statistics I made this formula (#1): =(SUBSTITUE(SUBSTITUE("=SUBSTITUE(GAUCHE(CELLULECHOISIE;TROUVE(¶;¶;CELLULECHOISIE)-1);¶[¶;¶¶)";"¶";"""");"CELLULECHOISIE";SUBSTITUE("VALEU...
NikolinoDE
Feb 08, 2024Platinum Contributor
To achieve the functionality you described, where a formula in a cell evaluates to another formula and then to its result, all within the same cell, you can use a VBA (Visual Basic for Applications) macro.
Here is a possible VBA approach/proposal:
Sub EvaluateFormula()
Dim rng As Range
Dim formula1 As String
Dim formula2 As String
Dim result As Variant
' Assuming the formula is in cell A1
Set rng = Range("A1")
' Get the formula from cell A1
formula1 = rng.Formula
' Evaluate the formula to get formula2
formula2 = Application.Evaluate(formula1)
' Evaluate formula2 to get the result
result = Application.Evaluate(formula2)
' Write the result back to the same cell (A1)
rng.Value = result
End SubMake sure you adjust the cell reference in the code if your formula is located in a different cell. The text was created with the help of AI.
My answers are voluntary and without guarantee!
Hope this will help you.
Was the answer useful? Mark as best response and like it!
This will help all forum participants.