Using substitute to define a user entered multi-variable function

kapo84

New Member
Joined
Nov 17, 2008
Messages
2
I have created a 4th order Runge Kutta Solver which will solve a pre-defined differential equation. I am trying to make the program more universal by allowing it to accept any user defined function. I have done this before for a polynomial but I am having problems extending that same application to a multi-variable equation.

I am using the substitute function but I am not sure how to use it for more than one variable.

t1y = WorksheetFunction.MultiSubstitute(f1, "x", x, f1, "y", y, f1, "z", z)
k1y = Evaluate(t1y)

where f1 is the user-defined funciton and x,y, and z are variables included in the function. The Excel error message states "Run-Time error 438: Object doesn't support this property or method"

The following code worked for my polynomial function:
fxl = WorksheetFunction.Substitute(funct, "x", xl)

where funct is the user-defined polynomial and xl is the varible.
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
You can nest Replace vba function like

Replace(Replace(Replace(f1, "x", x), "y", y), "z", z)
 
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,717
Members
448,985
Latest member
chocbudda

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