Dynamic Formula

Mark McInerney

Active Member
Joined
Apr 4, 2012
Messages
283
Office Version
  1. 365
Platform
  1. Windows
Hi All,

I want to dynamically link the entry in a cell to another formula - I tried using the indirect function, but cannot seem to get it to work.

Is this possible - what I am trying to get in Cell B4 is the number 5, and not "2+3". When working correctly I should be able to change Cell C2 to "-" or ">=" or "<=" or ">" and so on.

Thanks - Mark.


1650984376487.png


1650984402298.png
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Using a VBA custom function.

Book1 (version 1).xlsb
BCD
82+3
95
Sheet8
Cell Formulas
RangeFormula
B9B9=eval(B8&C8&D8)


VBA Code:
Function eval(s As String)
eval = Evaluate(s)
End Function
 
Upvote 0
HI,

Thanks for taking the time to review - when I put in the formula an error message comes back - I assume it is to do with the VBA code? Is there a way to bypass the VBA code required?

Thanks - Mark.
 
Upvote 0
Could use Power Query instead. Not sure if there is a way to do it using built-in formulas.

Book1 (version 1).xlsb
IJKL
8N1OperatorN2Table5
92+57
Sheet8


Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Eval = Table.TransformRows(Source, each Expression.Evaluate(Text.Combine(List.Transform(Record.ToList(_),Text.From))))
in
    Eval
 
Upvote 0
HI,

Thanks for taking the time to review - when I put in the formula an error message comes back - I assume it is to do with the VBA code? Is there a way to bypass the VBA code required?

Thanks - Mark.
You just need to drop that VBA code he posted in a blank General VBA module in that workbook, so that the formula recognizes it.

I personally do not know of any way to do it just with Excel formulas, and not involving something like VBA or Power Query.
 
Upvote 0
Did find another way. If you make a named range using the evaluate function you can do it without VBA.

Named Range Definition: =EVALUATE(Sheet8!B9)

I also named the range: xVAL

Book1 (version 1).xlsb
BCD
84+3
94+3
107
Sheet8
Cell Formulas
RangeFormula
B9B9=B8&C8&D8
B10B10=xVAL
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,191
Members
452,616
Latest member
intern444

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top