Need function to convert string to formula

General Ledger

Active Member
Joined
Dec 31, 2007
Messages
460
Dear All,

Using Excel 2007: I used the Concatenate function to create a string that looks like a formula. I need a function that converts the string to a formula. I don't want to use VBA or macro.

For example, in cell A4 is the formula =CONCATENATE("=",A1,"!",A2,A3) Where A1 is the name of a sheet such as January, where A2 is a letter such as Z that is a column reference, and where A3 is a number such as 100 that is a row reference. The Concatenate function returns a string =January!Z100 I want Excel to interpret this string as a formula and show the value from sheet January, cell Z100.

It seems this should be easy but I can not find the solution. I almost wish the answer is complicated so I don't think I am so stupid. If someone provides a simple solution, I might have to surrender my Microsoft Certified Trainer and Certified Application Specialist certificates.

Best regards,

General Ledger
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
=indirect(Cell Where Your Concat goes in here)

Or in your case: =Indirect(CONCATENATE(A1,"!",A2,A3))
 
Upvote 0
Blade Hunter,

@&#$*%! I have been thinking about this problem off and on for a long time and you solved it in seconds. My hat is off to you, my Master.

Thanks,

GL
 
Upvote 0
IF you have a more complicated formula you could use a Named Value

For example, if B3 held the STRING '=SUM(A1:A5)

Then the named formula
Name: calculatedValue
RefersTo: =EVALUATE(Sheet1!$B$3)

will return the value of the formula.

One drawback of this is that A1:A5 are not precedents of the formula, thus the formula will not refresh when they are changed.

A work-around for that would be to use
RefersTo: =IF(ROWS(Sheet1!$1:$65536)>0,EVALUATE(Sheet1!$B$3),)

where every cell of the sheet is a precedent cell for the named formula.
 
Upvote 0
Dear Mikerickson - This is magic sir. I was trying to implement something similar but nothing was working out. I wanted different formulas to execute based on certain criteria. I could build a very long choose formula but i wanted to keep it short by storing formulas as text string in cells. The method outlined by you made it possible.
 
Upvote 0
Mike,could you give a vba code UDF for ((200-100)*1.5) calculation as a result 150
if i have formula Sum((200-100)*1.5) i want to formulate it as ((200-100)*1.5)
could you help me?
 
Last edited:
Upvote 0
Code:
Function myEvaluate(aString) As Variant
    On Error Resume Next
        MyEvaluate = Evaluate(aString)
    On Error Goto 0
End Function
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,530
Messages
6,125,350
Members
449,220
Latest member
Edwin_SVRZ

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