Thread: VBA Functions
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bill Renaud Bill Renaud is offline
external usenet poster
 
Posts: 417
Default VBA Functions

A function has to have a return type (long, integer, double, string,
etc.) depending on the value of what you are returning.
Also, exactly what is Vector1? Is it a range of cells or an array of
values? What about DotProd? Is it the product of all of the values of
the cells in Vector1? Show us the math that would normally be done.

One possible interpretation (assuming Vector1 is a Range) (not tested):

Public Function DotProd(Vector1 as Range) as Double
Dim rngCell as Range
Dim dblDotProd as Double

dblDotProd = 1

For each rngCell in Vector1
dblDotProd = dblDotProd*rngCell.Value
next rngCell

DotProd = dblDotProd
End Function
--
Regards,
Bill Renaud