Possibility of creating VBA function including solver (goal seeker) or use Matlab

Dear Reader,

For a project I need to write my own function in excel (because that will reduce the complexity of my excel sheet considerably). The function needs 6 input variables and eventually returns the variable y_r. First it is assumed that y_r = 0.1 which is required for the calculation for deltaDLM. In deltaDLM a natural logarithm is used (Ln) but creates an error after running. The essential thing in the function is the iterative solution of y_r. By changing y_r deltaDLM will be almost equal to deltaD (=Error). When that condition is satisfied the correct y_r is found. This is the final outcome of my function.

This is what I already have (function is called LCP from Logarithmic Concentration Profile):

Function LCP(deltaD, p, pp, x_f, x_r, y_p)

y_r = 0.1

deltaDLM = ((x_f * p - y_p * pp) - (x_r * p - y_r * pp)) / Ln((x_f * p - y_p * pp) / (x_r * p - y_r * pp))

Error = deltaDLM - deltaD

Range("A1").Select

ActiveCell.FormulaR1C1 = y_r

Range("A2").Select

ActiveCell.FormulaR1C1 = Error

Range("A2").Select

Range("A2").GoalSeek Goal:=0, ChangingCell:=Range("A1")

End Function

Can anybody help me on this topic?