Don:
Thanks! That looks like what I need. Let me incorporate that into my
code and see what happens. I looked through the documentation for two
hours yesterday trying to find the "magic bullet". I think I looked
at "range" but surely didn't understand the explanation that MS
offered in the VBA help file.
--
Steve Spence
Independent AMSOIL Dealer
AMSOIL - The "Once A Year" Oil Change
35 Years of G.M. Parts Experience
URL:
http://synthetic-oil-tech.com/1690163
Email: (e-mail address removed)
| Function mi(x)
| Application.Volatile
| If x = Range("d1") Then mi = x * (Range("e1") + Range("e2"))
| End Function
|
| --
| Don Guillett
| Microsoft MVP Excel
| SalesAid Software
| (e-mail address removed)
| | > Bob:
| >
| > Thanks for the super quick reply; however, either I'm completely
lost
| > or you've misunderstood what I originally asked. Let me try again
and
| > if you get a stupid look on your face, I'll know it was me... LOL!
| >
| > Column B has a numerical value in it.
| > If the numerical value in A36 (just an arbitrary cell) happens
to
| > match the value in B2, then
| > multiply the values in C2 and D2 to get a product (ie:
total =
| > value(c2) * value(d2) )
| >
| > I don't understand how to get the contents of c2 or d2 into a
variable
| > inside my function since they aren't passed as an argument.
| >
| > Here's the logic in pseudocode:
| >
| > If Value(B2) = Value(A36)
| > Then
| > Product = Value(C2) * Value(D2)
| > Total = Total + Product
| > Endif
| >
| > The value being searched for in B2 could be listed again in
another
| > cell in the same column.
| >
| >
| > --
| > Steve Spence
| > Independent AMSOIL Dealer
| > AMSOIL - The "Once A Year" Oil Change
| > 35 Years of G.M. Parts Experience
| > URL:
http://synthetic-oil-tech.com/1690163
| > Email: (e-mail address removed)
| > | > | Function myFunction(rng As Range)
| > |
| > | If rn.Cells.Count > 1 Then
| > |
| > | myFunction = CVErr(xlErrValue)
| > | Else
| > |
| > | MsgBox rng.Value
| > | End If
| > | End Function
| > |
| > | and use in the worksheet lik so
| > |
| > | =myFunction(H10)
| > |
| > |
| > | --
| > | __________________________________
| > | HTH
| > |
| > | Bob
| > |
| > | | > | > Hi:
| > | >
| > | > I have BASIC programming skills but have never had the
opportunity
| > to
| > | > use VBA inside Excel.
| > | >
| > | > Using a UDF, I need to know how to take the contents of a cell
and
| > | > pass it to a variable inside my user defined function.
| > | >
| > | > I am trying to take the results in one cell and if it matches,
| > then
| > | > take the information from two other cells and multiply them
| > together.
| > | >
| > | > I've poured over the VBA documentation and see how to push a
value
| > | > into a cell, but can't find any examples of retrieving a
cell's
| > | > content.
| > | >
| > | > Thanks in advance!
| > | >
| > | > --
| > | > Steve Spence
| > | > Independent AMSOIL Dealer
| > | > AMSOIL - The "Once A Year" Oil Change
| > | > 35 Years of G.M. Parts Experience
| > | > URL:
http://synthetic-oil-tech.com/1690163
| > | > Email: (e-mail address removed)
| > | >
| > | >
| > |
| > |
| >
| >
|