First, unless you've defined your own type "Real", you need to use a
built-in type. Numeric values stored in XL cells are always of type
Double, so that's safe to use.
Second, you can't Dim a variable that you've already declared as an
argument in the function's argument list
Third, 'Set' is only used to assign an object variable to an object, for
instance, a range variable to a range as in
Dim rng As Range
Set rng = Workbooks("Sayaka").Sheets("Sheet1").Range("D34")
Now the variable rng can be used in place of the range object (in this
case, cell D34 of Sheet1 of workbook Sayaka).
Other (non-object) variables just use the assignment operator (=), so
for instance
Dim Reactant As Double
Dim Yield As Double
Reactant = rng.Value
Yield = rng.Value
So you might try:
Public Function Process1( _
ByVal Reactant As Double, _
ByVal Yield As Double) As Double
Dim AResult As Double
Dim BResult As Double
Dim CResult As Double
AResult = (Reactant / (1 - Yield))
BResult = (Reactant / (1 - Yield)) * 2
CResult = (Reactant / (1 - Yield)) * 3
Process1 = AResult + BResult + CResult
End Function
And call the function from the worksheet as
=Process1(Sheet1!D34, Sheet1!E34)
In article
<69af3779-3d00-4c20-b980-c5354f3c3f89@s19g2000prg.googlegroups.com>,
> I wonder if some one can tell me what is wrong with my code?
> I am having problems with the first line? I looked online and i
[quoted text clipped - 20 lines]
>
> End Function