|
-
Mar 23rd, 2005, 04:23 AM
#1
Thread Starter
Addicted Member
How to Write Formula Using Formula
Hi ...
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.
Last edited by LeonX; Mar 23rd, 2005 at 04:40 AM.
Regards,
Ferry
-
Mar 23rd, 2005, 05:28 AM
#2
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
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Mar 23rd, 2005, 10:05 PM
#3
Thread Starter
Addicted Member
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?
-
Mar 24th, 2005, 09:11 AM
#4
Addicted Member
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.
if you fail to plan, you plan to fail
-
Mar 24th, 2005, 01:52 PM
#5
Lively Member
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
-
Mar 24th, 2005, 01:55 PM
#6
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
-
Mar 27th, 2005, 08:45 PM
#7
Thread Starter
Addicted Member
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.
-
Mar 28th, 2005, 07:07 AM
#8
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??
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
-
Mar 28th, 2005, 12:29 PM
#9
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?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|