How to Write Formula Using Formula
Hi ... :wave:
I have question about excel.
I'm curious how can we write a formula using another formula?
Example:
In cell A1 I have value | 10 |
In cell B1 I have value | 10 |
In cell C1 I have value | =concatenate("=",A1,"+",B1) |
It will give me result in cell C1 | =10+10 |, is this possible if I want the result in cell C1 | 20 |? But not by typing formula | =A1+B1 | in cell C1.
Hope everyone understand my question.
Thanks for helping me solve this problem.
Re: How to Write Formula Using Formula
uhhh
Where do you want the result?
If its another cell, just put the formula in that cell of a1+b1
If you mean via code you'd need something like the following:
Code:
debug.print activeworkbook.activesheet.cells(1,1)+activeworkbook.activesheet.cells(1,2)
Of course its easier to have variables for the workbook and sheet.
Code:
dim wrk as workbook, sht as worksheet
set wrk = activeworkbook
set sht = wrk.activeworksheet 'or wrk.sheets("sheetname")
debug.print sht.cells(1,1)+sht.cells(1,2)
set sht=nothing
set wrk=nothing
Re: How to Write Formula Using Formula
sorry for making you confuse Ecniv :) ...
i will make it simple , can i evaluate formula | =concatenate("=",A1,"+",B1) | as a formula.
this | =concatenate("=",A1,"+",B1) | will give result | =10+10 | right.
i want the result from | =concatenate("=",A1,"+",B1) | become | 20 | maybe with another function like
| =EVALUATEASFORMULA(concatenate("=",A1,"+",B1)) |, my question, is there any function in excel like EVALUATEASFORMULA?
Re: How to Write Formula Using Formula
I think what you are trying to do is use the cell values as a formula.
and use those values to get a result.
seems a bit unecessary.
maybe if you explain your reasons for needing to do this, it would be easier to suggest a resolution.
Re: How to Write Formula Using Formula
did you tried to code something like this
VB Code:
formule = "=gauche(A2" & Chr(59) & "4)"
Range("A1").FormulaLocal = formule
:wave:
Re: How to Write Formula Using Formula
Before everyone pulls their head out of their arse and realize that it isn't truly VBA that you are doing here, but an Excel FORMULA.... See if you can do this:
=Eval (concatenate("=",A1,"+",B1))
I've not done this my self, and not sure why you would want to, but I think that will work.
Tg
Re: How to Write Formula Using Formula
thanks to techgnome, writelearner, Br1an_g, and everyone here, ...
4 techgnome:
i've already try your code but it didn't work.
4 writelearner:
i want to know the pure excel function not the vba.
4 Br1an_g:
for now i don't have any reason to do that, just curious.
Re: How to Write Formula Using Formula
I don't get your problem.
you want to get the result 20 in cell C1, but you don't want to put in the formula "=a1+b1". What do you want to put into that cell?? can you give an example??
Re: How to Write Formula Using Formula
eval is not supported in Excel but it does have an Evaluate function. But again, its VBA
and not valid as a formula input.
I dont understand the reasoning behind this. You want to add to cells together but not using
a formula or vba code?
Or are you trying to place a "formula text" in a cell but not as a formula. Then read the text formula
and put the resulting value of that "formula" into another cell?