Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

String to formula

Status
Not open for further replies.

imarosel

Technical User
Jun 23, 2005
149
US
Ok i'm banging my head on the following. I have a lot of custom formulas I want to work with.

here is a simple function
Function easy()

easy = 2

End Function

here is some code that works
Sheets("execution").Cells(introw, 5).Value = easy

but I want to grab the function names from a spreadsheet and throw them in and have that evaluate.
Sheets("execution").Cells(introw, 5).Value=sheets("other").cells(1,1).value

this does not work
Sheets("execution").Cells(introw, 5).Value=evaluate(sheets("other").cells(1,1).value)
 
Why do you want to evaluate it within your VBA? Why not have the functions refered to in cell formulae, and have them evaluated that way? Just curious, before starting to think of answers.

Cheers, Glenn.

Did you hear about the literalist show-jumper? He broke his nose jumping against the clock.
 
I think we are at risk of misunderstanding each other here do to my inexperience and lack of eloquence.

I'm building a simulator in Excel because I am told I have to use excel. I'm trying to build it in a way someone that doesn't understand vb or that much about excel can come along and make adjustments.

So far I have a 3 sheets. One of inputs, one that lists calculations and variables (about 100 different equations) and a sheet that is kind of a user interface where a user can string together an order of execution. The x axis on the input sheet is variable values, the y axis is time values. A lot of the formulas are sum of series formulas.

So far I have come up with writing a function for each equation and having the user string those function names together on the execution sheet, the code I have just figured out to answer my original question is:

Run(Sheets("execution").Cells(introw, 1).Value)

I would rather have a more graceful solution to this problem but I have less than a week to do it and I can't spend all day of each day solving it. Too bad too I like math and coding and I can put the two together now. I think I have found the answer to my original question but I am still open to advice, if I have time to implement the advice is another matter, however.

Thanks for your response.
 
something like:
Sheets("execution").Cells(introw, 5)= [red]"=" & [/red]sheets("other").cells(1,1) [red] & "()"[/red]

_________________
Bob Rashkin
 
I'm good on this, thanks everyone. I have another emergency posted if you would like to help. Please.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top